Coverage Report

Created: 2023-08-28 06:23

/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
805k
#define DOT_DEBUG ".debug"
366
804k
#define DOT_ZDEBUG  ".zdebug"
367
185k
#define GNU_LINKONCE_WI ".gnu.linkonce.wi."
368
185k
#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
338k
{
411
338k
  bfd_coff_long_section_names (abfd) = enable;
412
338k
  return true;
413
338k
}
pei-i386.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
6.30k
{
411
6.30k
  bfd_coff_long_section_names (abfd) = enable;
412
6.30k
  return true;
413
6.30k
}
pe-x86_64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
5.64k
{
411
5.64k
  bfd_coff_long_section_names (abfd) = enable;
412
5.64k
  return true;
413
5.64k
}
pei-x86_64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
3.81k
{
411
3.81k
  bfd_coff_long_section_names (abfd) = enable;
412
3.81k
  return true;
413
3.81k
}
pe-aarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
4.33k
{
411
4.33k
  bfd_coff_long_section_names (abfd) = enable;
412
4.33k
  return true;
413
4.33k
}
pei-aarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
7.84k
{
411
7.84k
  bfd_coff_long_section_names (abfd) = enable;
412
7.84k
  return true;
413
7.84k
}
pei-ia64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
4.87k
{
411
4.87k
  bfd_coff_long_section_names (abfd) = enable;
412
4.87k
  return true;
413
4.87k
}
pei-loongarch64.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
6.09k
{
411
6.09k
  bfd_coff_long_section_names (abfd) = enable;
412
6.09k
  return true;
413
6.09k
}
coff-go32.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
166k
{
411
166k
  bfd_coff_long_section_names (abfd) = enable;
412
166k
  return true;
413
166k
}
coff-stgo32.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
96.3k
{
411
96.3k
  bfd_coff_long_section_names (abfd) = enable;
412
96.3k
  return true;
413
96.3k
}
pe-arm-wince.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
3.23k
{
411
3.23k
  bfd_coff_long_section_names (abfd) = enable;
412
3.23k
  return true;
413
3.23k
}
pe-arm.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
3.23k
{
411
3.23k
  bfd_coff_long_section_names (abfd) = enable;
412
3.23k
  return true;
413
3.23k
}
pe-i386.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
5.14k
{
411
5.14k
  bfd_coff_long_section_names (abfd) = enable;
412
5.14k
  return true;
413
5.14k
}
pe-mcore.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
2.65k
{
411
2.65k
  bfd_coff_long_section_names (abfd) = enable;
412
2.65k
  return true;
413
2.65k
}
pe-sh.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
3.24k
{
411
3.24k
  bfd_coff_long_section_names (abfd) = enable;
412
3.24k
  return true;
413
3.24k
}
pei-arm-wince.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
5.01k
{
411
5.01k
  bfd_coff_long_section_names (abfd) = enable;
412
5.01k
  return true;
413
5.01k
}
pei-arm.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
6.15k
{
411
6.15k
  bfd_coff_long_section_names (abfd) = enable;
412
6.15k
  return true;
413
6.15k
}
pei-mcore.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
4.26k
{
411
4.26k
  bfd_coff_long_section_names (abfd) = enable;
412
4.26k
  return true;
413
4.26k
}
pei-sh.c:bfd_coff_set_long_section_names_allowed
Line
Count
Source
410
3.39k
{
411
3.39k
  bfd_coff_long_section_names (abfd) = enable;
412
3.39k
  return true;
413
3.39k
}
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
1.66M
{
419
1.66M
  return false;
420
1.66M
}
coff-x86_64.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
163k
{
419
163k
  return false;
420
163k
}
coff64-rs6000.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
84.1k
{
419
84.1k
  return false;
420
84.1k
}
cf-i386lynx.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
281k
{
419
281k
  return false;
420
281k
}
coff-i386.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
190k
{
419
190k
  return false;
420
190k
}
coff-rs6000.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
490k
{
419
490k
  return false;
420
490k
}
coff-sh.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
139k
{
419
139k
  return false;
420
139k
}
coff-tic30.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
204k
{
419
204k
  return false;
420
204k
}
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
25.7k
{
419
25.7k
  return false;
420
25.7k
}
coff-z80.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
36.2k
{
419
36.2k
  return false;
420
36.2k
}
coff-z8k.c:bfd_coff_set_long_section_names_disallowed
Line
Count
Source
418
44.1k
{
419
44.1k
  return false;
420
44.1k
}
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.92M
{
688
1.92M
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
1.92M
  unsigned long styp_flags = internal_s->s_flags;
690
1.92M
  flagword sec_flags = 0;
691
692
#ifdef STYP_BLOCK
693
25.7k
  if (styp_flags & STYP_BLOCK)
694
8.01k
    sec_flags |= SEC_TIC54X_BLOCK;
695
#endif
696
697
#ifdef STYP_CLINK
698
25.7k
  if (styp_flags & STYP_CLINK)
699
9.01k
    sec_flags |= SEC_TIC54X_CLINK;
700
#endif
701
702
1.92M
#ifdef STYP_NOLOAD
703
1.92M
  if (styp_flags & STYP_NOLOAD)
704
582k
    sec_flags |= SEC_NEVER_LOAD;
705
1.92M
#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.92M
  if (styp_flags & STYP_TEXT)
710
699k
    {
711
699k
      if (sec_flags & SEC_NEVER_LOAD)
712
391k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
308k
      else
714
308k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
699k
    }
716
1.22M
  else if (styp_flags & STYP_DATA)
717
163k
    {
718
163k
      if (sec_flags & SEC_NEVER_LOAD)
719
70.6k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
93.2k
      else
721
93.2k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
163k
    }
723
1.06M
  else if (styp_flags & STYP_BSS)
724
85.3k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
41.4k
      if (sec_flags & SEC_NEVER_LOAD)
727
14.2k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
27.1k
      else
729
27.1k
#endif
730
71.0k
  sec_flags |= SEC_ALLOC;
731
85.3k
    }
732
975k
  else if (styp_flags & STYP_INFO)
733
124k
    {
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
63.1k
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
124k
    }
744
851k
  else if (styp_flags & STYP_PAD)
745
65.7k
    sec_flags = 0;
746
#ifdef RS6000COFF_C
747
239k
  else if (styp_flags & STYP_TDATA)
748
15.8k
    {
749
15.8k
      if (sec_flags & SEC_NEVER_LOAD)
750
3.20k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
12.6k
      else
752
12.6k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
15.8k
    }
754
223k
  else if (styp_flags & STYP_TBSS)
755
15.1k
    {
756
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
757
      if (sec_flags & SEC_NEVER_LOAD)
758
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
759
      else
760
#endif
761
15.1k
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
15.1k
    }
763
208k
  else if (styp_flags & STYP_EXCEPT)
764
9.34k
    sec_flags |= SEC_LOAD;
765
199k
  else if (styp_flags & STYP_LOADER)
766
3.50k
    sec_flags |= SEC_LOAD;
767
195k
  else if (styp_flags & STYP_TYPCHK)
768
2.79k
    sec_flags |= SEC_LOAD;
769
193k
  else if (styp_flags & STYP_DWARF)
770
3.75k
    sec_flags |= SEC_DEBUGGING;
771
189k
#endif
772
735k
  else if (strcmp (name, _TEXT) == 0)
773
1.27k
    {
774
1.27k
      if (sec_flags & SEC_NEVER_LOAD)
775
375
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
896
      else
777
896
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
1.27k
    }
779
733k
  else if (strcmp (name, _DATA) == 0)
780
1.28k
    {
781
1.28k
      if (sec_flags & SEC_NEVER_LOAD)
782
192
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
1.09k
      else
784
1.09k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
1.28k
    }
786
732k
  else if (strcmp (name, _BSS) == 0)
787
1.70k
    {
788
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
698
      if (sec_flags & SEC_NEVER_LOAD)
790
35
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
663
      else
792
663
#endif
793
1.66k
  sec_flags |= SEC_ALLOC;
794
1.70k
    }
795
730k
  else if (startswith (name, DOT_DEBUG)
796
730k
     || startswith (name, DOT_ZDEBUG)
797
#ifdef _COMMENT
798
531k
     || strcmp (name, _COMMENT) == 0
799
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
111k
     || startswith (name, GNU_LINKONCE_WI)
802
111k
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
730k
     || startswith (name, ".stab"))
805
7.17k
    {
806
#ifdef COFF_PAGE_SIZE
807
4.69k
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
7.17k
    }
810
#ifdef _LIB
811
525k
  else if (strcmp (name, _LIB) == 0)
812
404
    ;
813
525k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
525k
  else
819
723k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
1.92M
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
1.92M
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
200k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
1.92M
#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.92M
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
1.92M
      && (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
262k
  if (startswith (name, ".gnu.linkonce"))
844
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
#endif
846
847
1.92M
  if (flags_ptr == NULL)
848
0
    return false;
849
850
1.92M
  * flags_ptr = sec_flags;
851
1.92M
  return true;
852
1.92M
}
coff-x86_64.c:styp_to_sec_flags
Line
Count
Source
687
163k
{
688
163k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
163k
  unsigned long styp_flags = internal_s->s_flags;
690
163k
  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
163k
#ifdef STYP_NOLOAD
703
163k
  if (styp_flags & STYP_NOLOAD)
704
58.2k
    sec_flags |= SEC_NEVER_LOAD;
705
163k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
163k
  if (styp_flags & STYP_TEXT)
710
57.4k
    {
711
57.4k
      if (sec_flags & SEC_NEVER_LOAD)
712
28.5k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
28.8k
      else
714
28.8k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
57.4k
    }
716
106k
  else if (styp_flags & STYP_DATA)
717
23.6k
    {
718
23.6k
      if (sec_flags & SEC_NEVER_LOAD)
719
10.6k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
13.0k
      else
721
13.0k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
23.6k
    }
723
82.6k
  else if (styp_flags & STYP_BSS)
724
13.6k
    {
725
13.6k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
13.6k
      if (sec_flags & SEC_NEVER_LOAD)
727
5.16k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
8.45k
      else
729
8.45k
#endif
730
8.45k
  sec_flags |= SEC_ALLOC;
731
13.6k
    }
732
68.9k
  else if (styp_flags & STYP_INFO)
733
17.1k
    {
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
17.1k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
17.1k
      sec_flags |= SEC_DEBUGGING;
742
17.1k
#endif
743
17.1k
    }
744
51.8k
  else if (styp_flags & STYP_PAD)
745
10.6k
    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
41.1k
  else if (strcmp (name, _TEXT) == 0)
773
90
    {
774
90
      if (sec_flags & SEC_NEVER_LOAD)
775
24
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
66
      else
777
66
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
90
    }
779
41.0k
  else if (strcmp (name, _DATA) == 0)
780
84
    {
781
84
      if (sec_flags & SEC_NEVER_LOAD)
782
11
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
73
      else
784
73
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
84
    }
786
41.0k
  else if (strcmp (name, _BSS) == 0)
787
82
    {
788
82
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
82
      if (sec_flags & SEC_NEVER_LOAD)
790
3
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
79
      else
792
79
#endif
793
79
  sec_flags |= SEC_ALLOC;
794
82
    }
795
40.9k
  else if (startswith (name, DOT_DEBUG)
796
40.9k
     || startswith (name, DOT_ZDEBUG)
797
40.9k
#ifdef _COMMENT
798
40.9k
     || strcmp (name, _COMMENT) == 0
799
40.9k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
40.9k
     || startswith (name, ".stab"))
805
497
    {
806
497
#ifdef COFF_PAGE_SIZE
807
497
      sec_flags |= SEC_DEBUGGING;
808
497
#endif
809
497
    }
810
40.4k
#ifdef _LIB
811
40.4k
  else if (strcmp (name, _LIB) == 0)
812
23
    ;
813
40.3k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
40.3k
  else
819
40.3k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
163k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
163k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
17.8k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
163k
#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
163k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
163k
      && (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
163k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
163k
  * flags_ptr = sec_flags;
851
163k
  return true;
852
163k
}
coff64-rs6000.c:styp_to_sec_flags
Line
Count
Source
687
84.1k
{
688
84.1k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
84.1k
  unsigned long styp_flags = internal_s->s_flags;
690
84.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
84.1k
#ifdef STYP_NOLOAD
703
84.1k
  if (styp_flags & STYP_NOLOAD)
704
24.7k
    sec_flags |= SEC_NEVER_LOAD;
705
84.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
84.1k
  if (styp_flags & STYP_TEXT)
710
29.6k
    {
711
29.6k
      if (sec_flags & SEC_NEVER_LOAD)
712
16.2k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
13.4k
      else
714
13.4k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
29.6k
    }
716
54.4k
  else if (styp_flags & STYP_DATA)
717
6.72k
    {
718
6.72k
      if (sec_flags & SEC_NEVER_LOAD)
719
3.61k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
3.10k
      else
721
3.10k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
6.72k
    }
723
47.6k
  else if (styp_flags & STYP_BSS)
724
2.63k
    {
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
2.63k
  sec_flags |= SEC_ALLOC;
731
2.63k
    }
732
45.0k
  else if (styp_flags & STYP_INFO)
733
5.71k
    {
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
5.71k
    }
744
39.3k
  else if (styp_flags & STYP_PAD)
745
2.41k
    sec_flags = 0;
746
36.9k
#ifdef RS6000COFF_C
747
36.9k
  else if (styp_flags & STYP_TDATA)
748
2.73k
    {
749
2.73k
      if (sec_flags & SEC_NEVER_LOAD)
750
494
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
2.24k
      else
752
2.24k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
2.73k
    }
754
34.1k
  else if (styp_flags & STYP_TBSS)
755
1.60k
    {
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
1.60k
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
1.60k
    }
763
32.5k
  else if (styp_flags & STYP_EXCEPT)
764
1.83k
    sec_flags |= SEC_LOAD;
765
30.7k
  else if (styp_flags & STYP_LOADER)
766
614
    sec_flags |= SEC_LOAD;
767
30.1k
  else if (styp_flags & STYP_TYPCHK)
768
412
    sec_flags |= SEC_LOAD;
769
29.7k
  else if (styp_flags & STYP_DWARF)
770
675
    sec_flags |= SEC_DEBUGGING;
771
29.0k
#endif
772
29.0k
  else if (strcmp (name, _TEXT) == 0)
773
18
    {
774
18
      if (sec_flags & SEC_NEVER_LOAD)
775
1
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
17
      else
777
17
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
18
    }
779
29.0k
  else if (strcmp (name, _DATA) == 0)
780
47
    {
781
47
      if (sec_flags & SEC_NEVER_LOAD)
782
18
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
29
      else
784
29
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
47
    }
786
28.9k
  else if (strcmp (name, _BSS) == 0)
787
112
    {
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
112
  sec_flags |= SEC_ALLOC;
794
112
    }
795
28.8k
  else if (startswith (name, DOT_DEBUG)
796
28.8k
     || 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
28.8k
     || startswith (name, ".stab"))
805
251
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
251
    }
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
28.6k
  else
819
28.6k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
84.1k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
84.1k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
9.53k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
84.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
84.1k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
84.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
84.1k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
84.1k
  * flags_ptr = sec_flags;
851
84.1k
  return true;
852
84.1k
}
cf-i386lynx.c:styp_to_sec_flags
Line
Count
Source
687
281k
{
688
281k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
281k
  unsigned long styp_flags = internal_s->s_flags;
690
281k
  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
281k
#ifdef STYP_NOLOAD
703
281k
  if (styp_flags & STYP_NOLOAD)
704
85.5k
    sec_flags |= SEC_NEVER_LOAD;
705
281k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
281k
  if (styp_flags & STYP_TEXT)
710
103k
    {
711
103k
      if (sec_flags & SEC_NEVER_LOAD)
712
61.2k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
42.0k
      else
714
42.0k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
103k
    }
716
178k
  else if (styp_flags & STYP_DATA)
717
21.4k
    {
718
21.4k
      if (sec_flags & SEC_NEVER_LOAD)
719
8.51k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
12.9k
      else
721
12.9k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
21.4k
    }
723
156k
  else if (styp_flags & STYP_BSS)
724
10.8k
    {
725
10.8k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
10.8k
      if (sec_flags & SEC_NEVER_LOAD)
727
3.50k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
7.37k
      else
729
7.37k
#endif
730
7.37k
  sec_flags |= SEC_ALLOC;
731
10.8k
    }
732
145k
  else if (styp_flags & STYP_INFO)
733
17.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
17.7k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
17.7k
      sec_flags |= SEC_DEBUGGING;
742
17.7k
#endif
743
17.7k
    }
744
128k
  else if (styp_flags & STYP_PAD)
745
7.70k
    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
120k
  else if (strcmp (name, _TEXT) == 0)
773
253
    {
774
253
      if (sec_flags & SEC_NEVER_LOAD)
775
81
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
172
      else
777
172
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
253
    }
779
120k
  else if (strcmp (name, _DATA) == 0)
780
227
    {
781
227
      if (sec_flags & SEC_NEVER_LOAD)
782
24
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
203
      else
784
203
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
227
    }
786
120k
  else if (strcmp (name, _BSS) == 0)
787
236
    {
788
236
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
236
      if (sec_flags & SEC_NEVER_LOAD)
790
11
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
225
      else
792
225
#endif
793
225
  sec_flags |= SEC_ALLOC;
794
236
    }
795
119k
  else if (startswith (name, DOT_DEBUG)
796
119k
     || startswith (name, DOT_ZDEBUG)
797
119k
#ifdef _COMMENT
798
119k
     || strcmp (name, _COMMENT) == 0
799
119k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
119k
     || startswith (name, ".stab"))
805
1.60k
    {
806
1.60k
#ifdef COFF_PAGE_SIZE
807
1.60k
      sec_flags |= SEC_DEBUGGING;
808
1.60k
#endif
809
1.60k
    }
810
118k
#ifdef _LIB
811
118k
  else if (strcmp (name, _LIB) == 0)
812
110
    ;
813
118k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
118k
  else
819
118k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
281k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
281k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
30.4k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
281k
#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
281k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
281k
      && (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
281k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
281k
  * flags_ptr = sec_flags;
851
281k
  return true;
852
281k
}
coff-go32.c:styp_to_sec_flags
Line
Count
Source
687
166k
{
688
166k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
166k
  unsigned long styp_flags = internal_s->s_flags;
690
166k
  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
166k
#ifdef STYP_NOLOAD
703
166k
  if (styp_flags & STYP_NOLOAD)
704
49.9k
    sec_flags |= SEC_NEVER_LOAD;
705
166k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
166k
  if (styp_flags & STYP_TEXT)
710
61.0k
    {
711
61.0k
      if (sec_flags & SEC_NEVER_LOAD)
712
36.1k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
24.9k
      else
714
24.9k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
61.0k
    }
716
105k
  else if (styp_flags & STYP_DATA)
717
12.4k
    {
718
12.4k
      if (sec_flags & SEC_NEVER_LOAD)
719
4.52k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
7.90k
      else
721
7.90k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
12.4k
    }
723
92.9k
  else if (styp_flags & STYP_BSS)
724
5.81k
    {
725
5.81k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
5.81k
      if (sec_flags & SEC_NEVER_LOAD)
727
1.99k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
3.81k
      else
729
3.81k
#endif
730
3.81k
  sec_flags |= SEC_ALLOC;
731
5.81k
    }
732
87.1k
  else if (styp_flags & STYP_INFO)
733
10.2k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
10.2k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
10.2k
      sec_flags |= SEC_DEBUGGING;
742
10.2k
#endif
743
10.2k
    }
744
76.9k
  else if (styp_flags & STYP_PAD)
745
4.96k
    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
71.9k
  else if (strcmp (name, _TEXT) == 0)
773
140
    {
774
140
      if (sec_flags & SEC_NEVER_LOAD)
775
56
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
84
      else
777
84
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
140
    }
779
71.8k
  else if (strcmp (name, _DATA) == 0)
780
110
    {
781
110
      if (sec_flags & SEC_NEVER_LOAD)
782
14
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
96
      else
784
96
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
110
    }
786
71.6k
  else if (strcmp (name, _BSS) == 0)
787
143
    {
788
143
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
143
      if (sec_flags & SEC_NEVER_LOAD)
790
10
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
133
      else
792
133
#endif
793
133
  sec_flags |= SEC_ALLOC;
794
143
    }
795
71.5k
  else if (startswith (name, DOT_DEBUG)
796
71.5k
     || startswith (name, DOT_ZDEBUG)
797
71.5k
#ifdef _COMMENT
798
71.5k
     || strcmp (name, _COMMENT) == 0
799
71.5k
#endif
800
71.5k
#ifdef COFF_LONG_SECTION_NAMES
801
71.5k
     || startswith (name, GNU_LINKONCE_WI)
802
71.5k
     || startswith (name, GNU_LINKONCE_WT)
803
71.5k
#endif
804
71.5k
     || startswith (name, ".stab"))
805
967
    {
806
967
#ifdef COFF_PAGE_SIZE
807
967
      sec_flags |= SEC_DEBUGGING;
808
967
#endif
809
967
    }
810
70.5k
#ifdef _LIB
811
70.5k
  else if (strcmp (name, _LIB) == 0)
812
71
    ;
813
70.5k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
70.5k
  else
819
70.5k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
166k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
166k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
17.8k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
166k
#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
166k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
166k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
166k
#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
166k
  if (startswith (name, ".gnu.linkonce"))
844
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
166k
#endif
846
847
166k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
166k
  * flags_ptr = sec_flags;
851
166k
  return true;
852
166k
}
coff-i386.c:styp_to_sec_flags
Line
Count
Source
687
190k
{
688
190k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
190k
  unsigned long styp_flags = internal_s->s_flags;
690
190k
  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
190k
#ifdef STYP_NOLOAD
703
190k
  if (styp_flags & STYP_NOLOAD)
704
56.9k
    sec_flags |= SEC_NEVER_LOAD;
705
190k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
190k
  if (styp_flags & STYP_TEXT)
710
69.7k
    {
711
69.7k
      if (sec_flags & SEC_NEVER_LOAD)
712
41.1k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
28.6k
      else
714
28.6k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
69.7k
    }
716
120k
  else if (styp_flags & STYP_DATA)
717
14.0k
    {
718
14.0k
      if (sec_flags & SEC_NEVER_LOAD)
719
5.21k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
8.87k
      else
721
8.87k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
14.0k
    }
723
106k
  else if (styp_flags & STYP_BSS)
724
6.76k
    {
725
6.76k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
6.76k
      if (sec_flags & SEC_NEVER_LOAD)
727
2.22k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
4.53k
      else
729
4.53k
#endif
730
4.53k
  sec_flags |= SEC_ALLOC;
731
6.76k
    }
732
100k
  else if (styp_flags & STYP_INFO)
733
11.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
11.8k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
11.8k
      sec_flags |= SEC_DEBUGGING;
742
11.8k
#endif
743
11.8k
    }
744
88.1k
  else if (styp_flags & STYP_PAD)
745
5.57k
    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
82.6k
  else if (strcmp (name, _TEXT) == 0)
773
143
    {
774
143
      if (sec_flags & SEC_NEVER_LOAD)
775
57
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
86
      else
777
86
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
143
    }
779
82.4k
  else if (strcmp (name, _DATA) == 0)
780
121
    {
781
121
      if (sec_flags & SEC_NEVER_LOAD)
782
16
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
105
      else
784
105
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
121
    }
786
82.3k
  else if (strcmp (name, _BSS) == 0)
787
164
    {
788
164
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
164
      if (sec_flags & SEC_NEVER_LOAD)
790
10
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
154
      else
792
154
#endif
793
154
  sec_flags |= SEC_ALLOC;
794
164
    }
795
82.1k
  else if (startswith (name, DOT_DEBUG)
796
82.1k
     || startswith (name, DOT_ZDEBUG)
797
82.1k
#ifdef _COMMENT
798
82.1k
     || strcmp (name, _COMMENT) == 0
799
82.1k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
82.1k
     || startswith (name, ".stab"))
805
1.04k
    {
806
1.04k
#ifdef COFF_PAGE_SIZE
807
1.04k
      sec_flags |= SEC_DEBUGGING;
808
1.04k
#endif
809
1.04k
    }
810
81.1k
#ifdef _LIB
811
81.1k
  else if (strcmp (name, _LIB) == 0)
812
71
    ;
813
81.0k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
81.0k
  else
819
81.0k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
190k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
190k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
19.8k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
190k
#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
190k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
190k
      && (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
190k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
190k
  * flags_ptr = sec_flags;
851
190k
  return true;
852
190k
}
coff-rs6000.c:styp_to_sec_flags
Line
Count
Source
687
490k
{
688
490k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
490k
  unsigned long styp_flags = internal_s->s_flags;
690
490k
  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
490k
#ifdef STYP_NOLOAD
703
490k
  if (styp_flags & STYP_NOLOAD)
704
141k
    sec_flags |= SEC_NEVER_LOAD;
705
490k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
490k
  if (styp_flags & STYP_TEXT)
710
171k
    {
711
171k
      if (sec_flags & SEC_NEVER_LOAD)
712
88.9k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
82.6k
      else
714
82.6k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
171k
    }
716
319k
  else if (styp_flags & STYP_DATA)
717
43.6k
    {
718
43.6k
      if (sec_flags & SEC_NEVER_LOAD)
719
19.7k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
23.9k
      else
721
23.9k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
43.6k
    }
723
275k
  else if (styp_flags & STYP_BSS)
724
22.9k
    {
725
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
      if (sec_flags & SEC_NEVER_LOAD)
727
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
      else
729
#endif
730
22.9k
  sec_flags |= SEC_ALLOC;
731
22.9k
    }
732
252k
  else if (styp_flags & STYP_INFO)
733
28.1k
    {
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
28.1k
    }
744
224k
  else if (styp_flags & STYP_PAD)
745
21.5k
    sec_flags = 0;
746
202k
#ifdef RS6000COFF_C
747
202k
  else if (styp_flags & STYP_TDATA)
748
13.1k
    {
749
13.1k
      if (sec_flags & SEC_NEVER_LOAD)
750
2.71k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_COFF_SHARED_LIBRARY;
751
10.4k
      else
752
10.4k
  sec_flags |= SEC_DATA | SEC_THREAD_LOCAL | SEC_LOAD | SEC_ALLOC;
753
13.1k
    }
754
189k
  else if (styp_flags & STYP_TBSS)
755
13.5k
    {
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
13.5k
  sec_flags |= SEC_ALLOC | SEC_THREAD_LOCAL;
762
13.5k
    }
763
176k
  else if (styp_flags & STYP_EXCEPT)
764
7.50k
    sec_flags |= SEC_LOAD;
765
168k
  else if (styp_flags & STYP_LOADER)
766
2.88k
    sec_flags |= SEC_LOAD;
767
165k
  else if (styp_flags & STYP_TYPCHK)
768
2.38k
    sec_flags |= SEC_LOAD;
769
163k
  else if (styp_flags & STYP_DWARF)
770
3.08k
    sec_flags |= SEC_DEBUGGING;
771
160k
#endif
772
160k
  else if (strcmp (name, _TEXT) == 0)
773
128
    {
774
128
      if (sec_flags & SEC_NEVER_LOAD)
775
8
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
120
      else
777
120
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
128
    }
779
160k
  else if (strcmp (name, _DATA) == 0)
780
207
    {
781
207
      if (sec_flags & SEC_NEVER_LOAD)
782
27
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
180
      else
784
180
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
207
    }
786
160k
  else if (strcmp (name, _BSS) == 0)
787
326
    {
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
326
  sec_flags |= SEC_ALLOC;
794
326
    }
795
159k
  else if (startswith (name, DOT_DEBUG)
796
159k
     || 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
159k
     || startswith (name, ".stab"))
805
320
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
320
    }
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
159k
  else
819
159k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
490k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
490k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
49.0k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
490k
#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
490k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
490k
      && (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
490k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
490k
  * flags_ptr = sec_flags;
851
490k
  return true;
852
490k
}
coff-sh.c:styp_to_sec_flags
Line
Count
Source
687
139k
{
688
139k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
139k
  unsigned long styp_flags = internal_s->s_flags;
690
139k
  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
139k
#ifdef STYP_NOLOAD
703
139k
  if (styp_flags & STYP_NOLOAD)
704
39.6k
    sec_flags |= SEC_NEVER_LOAD;
705
139k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
139k
  if (styp_flags & STYP_TEXT)
710
50.6k
    {
711
50.6k
      if (sec_flags & SEC_NEVER_LOAD)
712
28.2k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
22.3k
      else
714
22.3k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
50.6k
    }
716
88.9k
  else if (styp_flags & STYP_DATA)
717
10.3k
    {
718
10.3k
      if (sec_flags & SEC_NEVER_LOAD)
719
4.63k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
5.75k
      else
721
5.75k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
10.3k
    }
723
78.5k
  else if (styp_flags & STYP_BSS)
724
5.69k
    {
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
5.69k
  sec_flags |= SEC_ALLOC;
731
5.69k
    }
732
72.8k
  else if (styp_flags & STYP_INFO)
733
8.50k
    {
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
8.50k
    }
744
64.3k
  else if (styp_flags & STYP_PAD)
745
3.07k
    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
61.2k
  else if (strcmp (name, _TEXT) == 0)
773
74
    {
774
74
      if (sec_flags & SEC_NEVER_LOAD)
775
31
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
43
      else
777
43
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
74
    }
779
61.1k
  else if (strcmp (name, _DATA) == 0)
780
89
    {
781
89
      if (sec_flags & SEC_NEVER_LOAD)
782
19
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
70
      else
784
70
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
89
    }
786
61.0k
  else if (strcmp (name, _BSS) == 0)
787
209
    {
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
209
  sec_flags |= SEC_ALLOC;
794
209
    }
795
60.8k
  else if (startswith (name, DOT_DEBUG)
796
60.8k
     || startswith (name, DOT_ZDEBUG)
797
60.8k
#ifdef _COMMENT
798
60.8k
     || strcmp (name, _COMMENT) == 0
799
60.8k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
60.8k
     || startswith (name, ".stab"))
805
597
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
597
    }
810
60.2k
#ifdef _LIB
811
60.2k
  else if (strcmp (name, _LIB) == 0)
812
12
    ;
813
60.2k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
60.2k
  else
819
60.2k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
139k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
139k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
11.3k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
139k
#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
139k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
139k
      && (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
139k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
139k
  * flags_ptr = sec_flags;
851
139k
  return true;
852
139k
}
coff-stgo32.c:styp_to_sec_flags
Line
Count
Source
687
96.2k
{
688
96.2k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
96.2k
  unsigned long styp_flags = internal_s->s_flags;
690
96.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
96.2k
#ifdef STYP_NOLOAD
703
96.2k
  if (styp_flags & STYP_NOLOAD)
704
30.0k
    sec_flags |= SEC_NEVER_LOAD;
705
96.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
96.2k
  if (styp_flags & STYP_TEXT)
710
35.1k
    {
711
35.1k
      if (sec_flags & SEC_NEVER_LOAD)
712
21.0k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
14.0k
      else
714
14.0k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
35.1k
    }
716
61.1k
  else if (styp_flags & STYP_DATA)
717
7.82k
    {
718
7.82k
      if (sec_flags & SEC_NEVER_LOAD)
719
3.50k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
4.31k
      else
721
4.31k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
7.82k
    }
723
53.3k
  else if (styp_flags & STYP_BSS)
724
4.35k
    {
725
4.35k
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
726
4.35k
      if (sec_flags & SEC_NEVER_LOAD)
727
1.36k
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
728
2.98k
      else
729
2.98k
#endif
730
2.98k
  sec_flags |= SEC_ALLOC;
731
4.35k
    }
732
48.9k
  else if (styp_flags & STYP_INFO)
733
6.14k
    {
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
6.14k
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
6.14k
      sec_flags |= SEC_DEBUGGING;
742
6.14k
#endif
743
6.14k
    }
744
42.8k
  else if (styp_flags & STYP_PAD)
745
2.25k
    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
40.5k
  else if (strcmp (name, _TEXT) == 0)
773
110
    {
774
110
      if (sec_flags & SEC_NEVER_LOAD)
775
24
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
86
      else
777
86
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
110
    }
779
40.4k
  else if (strcmp (name, _DATA) == 0)
780
108
    {
781
108
      if (sec_flags & SEC_NEVER_LOAD)
782
8
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
100
      else
784
100
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
108
    }
786
40.3k
  else if (strcmp (name, _BSS) == 0)
787
73
    {
788
73
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
789
73
      if (sec_flags & SEC_NEVER_LOAD)
790
1
  sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
791
72
      else
792
72
#endif
793
72
  sec_flags |= SEC_ALLOC;
794
73
    }
795
40.2k
  else if (startswith (name, DOT_DEBUG)
796
40.2k
     || startswith (name, DOT_ZDEBUG)
797
40.2k
#ifdef _COMMENT
798
40.2k
     || strcmp (name, _COMMENT) == 0
799
40.2k
#endif
800
40.2k
#ifdef COFF_LONG_SECTION_NAMES
801
40.2k
     || startswith (name, GNU_LINKONCE_WI)
802
40.2k
     || startswith (name, GNU_LINKONCE_WT)
803
40.2k
#endif
804
40.2k
     || startswith (name, ".stab"))
805
577
    {
806
577
#ifdef COFF_PAGE_SIZE
807
577
      sec_flags |= SEC_DEBUGGING;
808
577
#endif
809
577
    }
810
39.6k
#ifdef _LIB
811
39.6k
  else if (strcmp (name, _LIB) == 0)
812
39
    ;
813
39.6k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
39.6k
  else
819
39.6k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
96.2k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
96.2k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
11.0k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
96.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
96.2k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
96.2k
      && (startswith (name, ".sbss")
833
0
    || startswith (name, ".sdata")))
834
0
    sec_flags |= SEC_SMALL_DATA;
835
836
96.2k
#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
96.2k
  if (startswith (name, ".gnu.linkonce"))
844
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
845
96.2k
#endif
846
847
96.2k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
96.2k
  * flags_ptr = sec_flags;
851
96.2k
  return true;
852
96.2k
}
coff-tic30.c:styp_to_sec_flags
Line
Count
Source
687
204k
{
688
204k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
204k
  unsigned long styp_flags = internal_s->s_flags;
690
204k
  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
204k
#ifdef STYP_NOLOAD
703
204k
  if (styp_flags & STYP_NOLOAD)
704
61.4k
    sec_flags |= SEC_NEVER_LOAD;
705
204k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
204k
  if (styp_flags & STYP_TEXT)
710
78.2k
    {
711
78.2k
      if (sec_flags & SEC_NEVER_LOAD)
712
45.7k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
32.4k
      else
714
32.4k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
78.2k
    }
716
126k
  else if (styp_flags & STYP_DATA)
717
15.0k
    {
718
15.0k
      if (sec_flags & SEC_NEVER_LOAD)
719
6.04k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
9.01k
      else
721
9.01k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
15.0k
    }
723
111k
  else if (styp_flags & STYP_BSS)
724
8.42k
    {
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
8.42k
  sec_flags |= SEC_ALLOC;
731
8.42k
    }
732
103k
  else if (styp_flags & STYP_INFO)
733
11.9k
    {
734
      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
735
   defined.  coff_compute_section_file_positions uses
736
   COFF_PAGE_SIZE to ensure that the low order bits of the
737
   section VMA and the file offset match.  If we don't know
738
   COFF_PAGE_SIZE, we can't ensure the correct correspondence,
739
   and demand page loading of the file will fail.  */
740
#if defined (COFF_PAGE_SIZE) && !defined (COFF_ALIGN_IN_S_FLAGS)
741
      sec_flags |= SEC_DEBUGGING;
742
#endif
743
11.9k
    }
744
91.2k
  else if (styp_flags & STYP_PAD)
745
4.67k
    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
86.5k
  else if (strcmp (name, _TEXT) == 0)
773
187
    {
774
187
      if (sec_flags & SEC_NEVER_LOAD)
775
45
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
142
      else
777
142
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
187
    }
779
86.3k
  else if (strcmp (name, _DATA) == 0)
780
151
    {
781
151
      if (sec_flags & SEC_NEVER_LOAD)
782
17
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
134
      else
784
134
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
151
    }
786
86.2k
  else if (strcmp (name, _BSS) == 0)
787
219
    {
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
219
  sec_flags |= SEC_ALLOC;
794
219
    }
795
85.9k
  else if (startswith (name, DOT_DEBUG)
796
85.9k
     || startswith (name, DOT_ZDEBUG)
797
85.9k
#ifdef _COMMENT
798
85.9k
     || strcmp (name, _COMMENT) == 0
799
85.9k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
85.9k
     || startswith (name, ".stab"))
805
800
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
800
    }
810
85.1k
#ifdef _LIB
811
85.1k
  else if (strcmp (name, _LIB) == 0)
812
72
    ;
813
85.1k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
85.1k
  else
819
85.1k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
204k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
204k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
19.9k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
204k
#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
204k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
204k
      && (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
204k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
204k
  * flags_ptr = sec_flags;
851
204k
  return true;
852
204k
}
Unexecuted instantiation: coff-tic4x.c:styp_to_sec_flags
coff-tic54x.c:styp_to_sec_flags
Line
Count
Source
687
25.7k
{
688
25.7k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
25.7k
  unsigned long styp_flags = internal_s->s_flags;
690
25.7k
  flagword sec_flags = 0;
691
692
25.7k
#ifdef STYP_BLOCK
693
25.7k
  if (styp_flags & STYP_BLOCK)
694
8.01k
    sec_flags |= SEC_TIC54X_BLOCK;
695
25.7k
#endif
696
697
25.7k
#ifdef STYP_CLINK
698
25.7k
  if (styp_flags & STYP_CLINK)
699
9.01k
    sec_flags |= SEC_TIC54X_CLINK;
700
25.7k
#endif
701
702
25.7k
#ifdef STYP_NOLOAD
703
25.7k
  if (styp_flags & STYP_NOLOAD)
704
8.16k
    sec_flags |= SEC_NEVER_LOAD;
705
25.7k
#endif /* STYP_NOLOAD */
706
707
  /* For 386 COFF, at least, an unloadable text or data section is
708
     actually a shared library section.  */
709
25.7k
  if (styp_flags & STYP_TEXT)
710
9.73k
    {
711
9.73k
      if (sec_flags & SEC_NEVER_LOAD)
712
5.31k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
4.41k
      else
714
4.41k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
9.73k
    }
716
16.0k
  else if (styp_flags & STYP_DATA)
717
2.34k
    {
718
2.34k
      if (sec_flags & SEC_NEVER_LOAD)
719
1.21k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
1.12k
      else
721
1.12k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
2.34k
    }
723
13.6k
  else if (styp_flags & STYP_BSS)
724
1.07k
    {
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.07k
  sec_flags |= SEC_ALLOC;
731
1.07k
    }
732
12.6k
  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
11.2k
  else if (styp_flags & STYP_PAD)
745
949
    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
10.2k
  else if (strcmp (name, _TEXT) == 0)
773
46
    {
774
46
      if (sec_flags & SEC_NEVER_LOAD)
775
10
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
36
      else
777
36
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
46
    }
779
10.2k
  else if (strcmp (name, _DATA) == 0)
780
32
    {
781
32
      if (sec_flags & SEC_NEVER_LOAD)
782
11
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
21
      else
784
21
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
32
    }
786
10.1k
  else if (strcmp (name, _BSS) == 0)
787
28
    {
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
28
  sec_flags |= SEC_ALLOC;
794
28
    }
795
10.1k
  else if (startswith (name, DOT_DEBUG)
796
10.1k
     || 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
10.1k
     || startswith (name, ".stab"))
805
155
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
155
    }
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
10.0k
  else
819
10.0k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
25.7k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
25.7k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
3.42k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
25.7k
#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
25.7k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
25.7k
      && (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
25.7k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
25.7k
  * flags_ptr = sec_flags;
851
25.7k
  return true;
852
25.7k
}
coff-z80.c:styp_to_sec_flags
Line
Count
Source
687
36.2k
{
688
36.2k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
36.2k
  unsigned long styp_flags = internal_s->s_flags;
690
36.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
36.2k
#ifdef STYP_NOLOAD
703
36.2k
  if (styp_flags & STYP_NOLOAD)
704
12.2k
    sec_flags |= SEC_NEVER_LOAD;
705
36.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
36.2k
  if (styp_flags & STYP_TEXT)
710
14.7k
    {
711
14.7k
      if (sec_flags & SEC_NEVER_LOAD)
712
8.83k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
5.93k
      else
714
5.93k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
14.7k
    }
716
21.5k
  else if (styp_flags & STYP_DATA)
717
2.79k
    {
718
2.79k
      if (sec_flags & SEC_NEVER_LOAD)
719
1.27k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
1.52k
      else
721
1.52k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
2.79k
    }
723
18.7k
  else if (styp_flags & STYP_BSS)
724
1.32k
    {
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.32k
  sec_flags |= SEC_ALLOC;
731
1.32k
    }
732
17.4k
  else if (styp_flags & STYP_INFO)
733
2.55k
    {
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.55k
    }
744
14.8k
  else if (styp_flags & STYP_PAD)
745
1.03k
    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
13.8k
  else if (strcmp (name, _TEXT) == 0)
773
30
    {
774
30
      if (sec_flags & SEC_NEVER_LOAD)
775
3
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
27
      else
777
27
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
30
    }
779
13.7k
  else if (strcmp (name, _DATA) == 0)
780
50
    {
781
50
      if (sec_flags & SEC_NEVER_LOAD)
782
17
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
33
      else
784
33
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
50
    }
786
13.7k
  else if (strcmp (name, _BSS) == 0)
787
45
    {
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
45
  sec_flags |= SEC_ALLOC;
794
45
    }
795
13.6k
  else if (startswith (name, DOT_DEBUG)
796
13.6k
     || startswith (name, DOT_ZDEBUG)
797
13.6k
#ifdef _COMMENT
798
13.6k
     || strcmp (name, _COMMENT) == 0
799
13.6k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
13.6k
     || startswith (name, ".stab"))
805
204
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
204
    }
810
13.4k
#ifdef _LIB
811
13.4k
  else if (strcmp (name, _LIB) == 0)
812
3
    ;
813
13.4k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
13.4k
  else
819
13.4k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
36.2k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
36.2k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
4.45k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
36.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
36.2k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
36.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
36.2k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
36.2k
  * flags_ptr = sec_flags;
851
36.2k
  return true;
852
36.2k
}
coff-z8k.c:styp_to_sec_flags
Line
Count
Source
687
44.1k
{
688
44.1k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
689
44.1k
  unsigned long styp_flags = internal_s->s_flags;
690
44.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
44.1k
#ifdef STYP_NOLOAD
703
44.1k
  if (styp_flags & STYP_NOLOAD)
704
13.9k
    sec_flags |= SEC_NEVER_LOAD;
705
44.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
44.1k
  if (styp_flags & STYP_TEXT)
710
18.1k
    {
711
18.1k
      if (sec_flags & SEC_NEVER_LOAD)
712
9.85k
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
713
8.32k
      else
714
8.32k
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
715
18.1k
    }
716
25.9k
  else if (styp_flags & STYP_DATA)
717
3.49k
    {
718
3.49k
      if (sec_flags & SEC_NEVER_LOAD)
719
1.80k
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
720
1.68k
      else
721
1.68k
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
722
3.49k
    }
723
22.4k
  else if (styp_flags & STYP_BSS)
724
1.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
1.75k
  sec_flags |= SEC_ALLOC;
731
1.75k
    }
732
20.7k
  else if (styp_flags & STYP_INFO)
733
2.72k
    {
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.72k
    }
744
17.9k
  else if (styp_flags & STYP_PAD)
745
926
    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
17.0k
  else if (strcmp (name, _TEXT) == 0)
773
52
    {
774
52
      if (sec_flags & SEC_NEVER_LOAD)
775
35
  sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
776
17
      else
777
17
  sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
778
52
    }
779
17.0k
  else if (strcmp (name, _DATA) == 0)
780
57
    {
781
57
      if (sec_flags & SEC_NEVER_LOAD)
782
10
  sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
783
47
      else
784
47
  sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
785
57
    }
786
16.9k
  else if (strcmp (name, _BSS) == 0)
787
65
    {
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
65
  sec_flags |= SEC_ALLOC;
794
65
    }
795
16.8k
  else if (startswith (name, DOT_DEBUG)
796
16.8k
     || startswith (name, DOT_ZDEBUG)
797
16.8k
#ifdef _COMMENT
798
16.8k
     || strcmp (name, _COMMENT) == 0
799
16.8k
#endif
800
#ifdef COFF_LONG_SECTION_NAMES
801
     || startswith (name, GNU_LINKONCE_WI)
802
     || startswith (name, GNU_LINKONCE_WT)
803
#endif
804
16.8k
     || startswith (name, ".stab"))
805
157
    {
806
#ifdef COFF_PAGE_SIZE
807
      sec_flags |= SEC_DEBUGGING;
808
#endif
809
157
    }
810
16.7k
#ifdef _LIB
811
16.7k
  else if (strcmp (name, _LIB) == 0)
812
3
    ;
813
16.7k
#endif
814
#ifdef _LIT
815
  else if (strcmp (name, _LIT) == 0)
816
    sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
817
#endif
818
16.7k
  else
819
16.7k
    sec_flags |= SEC_ALLOC | SEC_LOAD;
820
821
44.1k
#ifdef STYP_LIT     /* A29k readonly text/data section type.  */
822
44.1k
  if ((styp_flags & STYP_LIT) == STYP_LIT)
823
5.25k
    sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY);
824
44.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
44.1k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
832
44.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
44.1k
  if (flags_ptr == NULL)
848
0
    return false;
849
850
44.1k
  * flags_ptr = sec_flags;
851
44.1k
  return true;
852
44.1k
}
853
854
#else /* COFF_WITH_PE */
855
856
static hashval_t
857
comdat_hashf (const void *entry)
858
346k
{
859
346k
  const struct comdat_hash_entry *fe = entry;
860
346k
  return fe->target_index;
861
346k
}
pei-i386.c:comdat_hashf
Line
Count
Source
858
858
{
859
858
  const struct comdat_hash_entry *fe = entry;
860
858
  return fe->target_index;
861
858
}
pe-x86_64.c:comdat_hashf
Line
Count
Source
858
3.84k
{
859
3.84k
  const struct comdat_hash_entry *fe = entry;
860
3.84k
  return fe->target_index;
861
3.84k
}
pei-x86_64.c:comdat_hashf
Line
Count
Source
858
9.00k
{
859
9.00k
  const struct comdat_hash_entry *fe = entry;
860
9.00k
  return fe->target_index;
861
9.00k
}
pe-aarch64.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
}
pei-aarch64.c:comdat_hashf
Line
Count
Source
858
251k
{
859
251k
  const struct comdat_hash_entry *fe = entry;
860
251k
  return fe->target_index;
861
251k
}
pei-ia64.c:comdat_hashf
Line
Count
Source
858
7.97k
{
859
7.97k
  const struct comdat_hash_entry *fe = entry;
860
7.97k
  return fe->target_index;
861
7.97k
}
pei-loongarch64.c:comdat_hashf
Line
Count
Source
858
25.9k
{
859
25.9k
  const struct comdat_hash_entry *fe = entry;
860
25.9k
  return fe->target_index;
861
25.9k
}
pe-arm-wince.c:comdat_hashf
Line
Count
Source
858
6.28k
{
859
6.28k
  const struct comdat_hash_entry *fe = entry;
860
6.28k
  return fe->target_index;
861
6.28k
}
pe-arm.c:comdat_hashf
Line
Count
Source
858
6.28k
{
859
6.28k
  const struct comdat_hash_entry *fe = entry;
860
6.28k
  return fe->target_index;
861
6.28k
}
pe-i386.c:comdat_hashf
Line
Count
Source
858
3.15k
{
859
3.15k
  const struct comdat_hash_entry *fe = entry;
860
3.15k
  return fe->target_index;
861
3.15k
}
pe-mcore.c:comdat_hashf
Line
Count
Source
858
3.91k
{
859
3.91k
  const struct comdat_hash_entry *fe = entry;
860
3.91k
  return fe->target_index;
861
3.91k
}
pe-sh.c:comdat_hashf
Line
Count
Source
858
11.9k
{
859
11.9k
  const struct comdat_hash_entry *fe = entry;
860
11.9k
  return fe->target_index;
861
11.9k
}
pei-arm-wince.c:comdat_hashf
Line
Count
Source
858
4.17k
{
859
4.17k
  const struct comdat_hash_entry *fe = entry;
860
4.17k
  return fe->target_index;
861
4.17k
}
pei-arm.c:comdat_hashf
Line
Count
Source
858
4.54k
{
859
4.54k
  const struct comdat_hash_entry *fe = entry;
860
4.54k
  return fe->target_index;
861
4.54k
}
pei-mcore.c:comdat_hashf
Line
Count
Source
858
4.27k
{
859
4.27k
  const struct comdat_hash_entry *fe = entry;
860
4.27k
  return fe->target_index;
861
4.27k
}
pei-sh.c:comdat_hashf
Line
Count
Source
858
1.63k
{
859
1.63k
  const struct comdat_hash_entry *fe = entry;
860
1.63k
  return fe->target_index;
861
1.63k
}
862
863
static int
864
comdat_eqf (const void *e1, const void *e2)
865
318k
{
866
318k
  const struct comdat_hash_entry *fe1 = e1;
867
318k
  const struct comdat_hash_entry *fe2 = e2;
868
318k
  return fe1->target_index == fe2->target_index;
869
318k
}
pei-i386.c:comdat_eqf
Line
Count
Source
865
359
{
866
359
  const struct comdat_hash_entry *fe1 = e1;
867
359
  const struct comdat_hash_entry *fe2 = e2;
868
359
  return fe1->target_index == fe2->target_index;
869
359
}
pe-x86_64.c:comdat_eqf
Line
Count
Source
865
2.24k
{
866
2.24k
  const struct comdat_hash_entry *fe1 = e1;
867
2.24k
  const struct comdat_hash_entry *fe2 = e2;
868
2.24k
  return fe1->target_index == fe2->target_index;
869
2.24k
}
pei-x86_64.c:comdat_eqf
Line
Count
Source
865
7.09k
{
866
7.09k
  const struct comdat_hash_entry *fe1 = e1;
867
7.09k
  const struct comdat_hash_entry *fe2 = e2;
868
7.09k
  return fe1->target_index == fe2->target_index;
869
7.09k
}
pe-aarch64.c:comdat_eqf
Line
Count
Source
865
280
{
866
280
  const struct comdat_hash_entry *fe1 = e1;
867
280
  const struct comdat_hash_entry *fe2 = e2;
868
280
  return fe1->target_index == fe2->target_index;
869
280
}
pei-aarch64.c:comdat_eqf
Line
Count
Source
865
239k
{
866
239k
  const struct comdat_hash_entry *fe1 = e1;
867
239k
  const struct comdat_hash_entry *fe2 = e2;
868
239k
  return fe1->target_index == fe2->target_index;
869
239k
}
pei-ia64.c:comdat_eqf
Line
Count
Source
865
9.80k
{
866
9.80k
  const struct comdat_hash_entry *fe1 = e1;
867
9.80k
  const struct comdat_hash_entry *fe2 = e2;
868
9.80k
  return fe1->target_index == fe2->target_index;
869
9.80k
}
pei-loongarch64.c:comdat_eqf
Line
Count
Source
865
21.8k
{
866
21.8k
  const struct comdat_hash_entry *fe1 = e1;
867
21.8k
  const struct comdat_hash_entry *fe2 = e2;
868
21.8k
  return fe1->target_index == fe2->target_index;
869
21.8k
}
pe-arm-wince.c:comdat_eqf
Line
Count
Source
865
5.00k
{
866
5.00k
  const struct comdat_hash_entry *fe1 = e1;
867
5.00k
  const struct comdat_hash_entry *fe2 = e2;
868
5.00k
  return fe1->target_index == fe2->target_index;
869
5.00k
}
pe-arm.c:comdat_eqf
Line
Count
Source
865
5.00k
{
866
5.00k
  const struct comdat_hash_entry *fe1 = e1;
867
5.00k
  const struct comdat_hash_entry *fe2 = e2;
868
5.00k
  return fe1->target_index == fe2->target_index;
869
5.00k
}
pe-i386.c:comdat_eqf
Line
Count
Source
865
1.94k
{
866
1.94k
  const struct comdat_hash_entry *fe1 = e1;
867
1.94k
  const struct comdat_hash_entry *fe2 = e2;
868
1.94k
  return fe1->target_index == fe2->target_index;
869
1.94k
}
pe-mcore.c:comdat_eqf
Line
Count
Source
865
3.33k
{
866
3.33k
  const struct comdat_hash_entry *fe1 = e1;
867
3.33k
  const struct comdat_hash_entry *fe2 = e2;
868
3.33k
  return fe1->target_index == fe2->target_index;
869
3.33k
}
pe-sh.c:comdat_eqf
Line
Count
Source
865
10.6k
{
866
10.6k
  const struct comdat_hash_entry *fe1 = e1;
867
10.6k
  const struct comdat_hash_entry *fe2 = e2;
868
10.6k
  return fe1->target_index == fe2->target_index;
869
10.6k
}
pei-arm-wince.c:comdat_eqf
Line
Count
Source
865
2.96k
{
866
2.96k
  const struct comdat_hash_entry *fe1 = e1;
867
2.96k
  const struct comdat_hash_entry *fe2 = e2;
868
2.96k
  return fe1->target_index == fe2->target_index;
869
2.96k
}
pei-arm.c:comdat_eqf
Line
Count
Source
865
3.09k
{
866
3.09k
  const struct comdat_hash_entry *fe1 = e1;
867
3.09k
  const struct comdat_hash_entry *fe2 = e2;
868
3.09k
  return fe1->target_index == fe2->target_index;
869
3.09k
}
pei-mcore.c:comdat_eqf
Line
Count
Source
865
3.83k
{
866
3.83k
  const struct comdat_hash_entry *fe1 = e1;
867
3.83k
  const struct comdat_hash_entry *fe2 = e2;
868
3.83k
  return fe1->target_index == fe2->target_index;
869
3.83k
}
pei-sh.c:comdat_eqf
Line
Count
Source
865
1.12k
{
866
1.12k
  const struct comdat_hash_entry *fe1 = e1;
867
1.12k
  const struct comdat_hash_entry *fe2 = e2;
868
1.12k
  return fe1->target_index == fe2->target_index;
869
1.12k
}
870
871
static void
872
comdat_delf (void *ent)
873
27.9k
{
874
27.9k
  struct comdat_hash_entry *e = ent;
875
27.9k
  free (e->symname);
876
27.9k
  free (e);
877
27.9k
}
pei-i386.c:comdat_delf
Line
Count
Source
873
146
{
874
146
  struct comdat_hash_entry *e = ent;
875
146
  free (e->symname);
876
146
  free (e);
877
146
}
pe-x86_64.c:comdat_delf
Line
Count
Source
873
847
{
874
847
  struct comdat_hash_entry *e = ent;
875
847
  free (e->symname);
876
847
  free (e);
877
847
}
pei-x86_64.c:comdat_delf
Line
Count
Source
873
1.90k
{
874
1.90k
  struct comdat_hash_entry *e = ent;
875
1.90k
  free (e->symname);
876
1.90k
  free (e);
877
1.90k
}
pe-aarch64.c:comdat_delf
Line
Count
Source
873
171
{
874
171
  struct comdat_hash_entry *e = ent;
875
171
  free (e->symname);
876
171
  free (e);
877
171
}
pei-aarch64.c:comdat_delf
Line
Count
Source
873
10.6k
{
874
10.6k
  struct comdat_hash_entry *e = ent;
875
10.6k
  free (e->symname);
876
10.6k
  free (e);
877
10.6k
}
pei-ia64.c:comdat_delf
Line
Count
Source
873
1.09k
{
874
1.09k
  struct comdat_hash_entry *e = ent;
875
1.09k
  free (e->symname);
876
1.09k
  free (e);
877
1.09k
}
pei-loongarch64.c:comdat_delf
Line
Count
Source
873
4.32k
{
874
4.32k
  struct comdat_hash_entry *e = ent;
875
4.32k
  free (e->symname);
876
4.32k
  free (e);
877
4.32k
}
pe-arm-wince.c:comdat_delf
Line
Count
Source
873
1.18k
{
874
1.18k
  struct comdat_hash_entry *e = ent;
875
1.18k
  free (e->symname);
876
1.18k
  free (e);
877
1.18k
}
pe-arm.c:comdat_delf
Line
Count
Source
873
1.18k
{
874
1.18k
  struct comdat_hash_entry *e = ent;
875
1.18k
  free (e->symname);
876
1.18k
  free (e);
877
1.18k
}
pe-i386.c:comdat_delf
Line
Count
Source
873
653
{
874
653
  struct comdat_hash_entry *e = ent;
875
653
  free (e->symname);
876
653
  free (e);
877
653
}
pe-mcore.c:comdat_delf
Line
Count
Source
873
707
{
874
707
  struct comdat_hash_entry *e = ent;
875
707
  free (e->symname);
876
707
  free (e);
877
707
}
pe-sh.c:comdat_delf
Line
Count
Source
873
1.80k
{
874
1.80k
  struct comdat_hash_entry *e = ent;
875
1.80k
  free (e->symname);
876
1.80k
  free (e);
877
1.80k
}
pei-arm-wince.c:comdat_delf
Line
Count
Source
873
1.19k
{
874
1.19k
  struct comdat_hash_entry *e = ent;
875
1.19k
  free (e->symname);
876
1.19k
  free (e);
877
1.19k
}
pei-arm.c:comdat_delf
Line
Count
Source
873
1.24k
{
874
1.24k
  struct comdat_hash_entry *e = ent;
875
1.24k
  free (e->symname);
876
1.24k
  free (e);
877
1.24k
}
pei-mcore.c:comdat_delf
Line
Count
Source
873
656
{
874
656
  struct comdat_hash_entry *e = ent;
875
656
  free (e->symname);
876
656
  free (e);
877
656
}
pei-sh.c:comdat_delf
Line
Count
Source
873
257
{
874
257
  struct comdat_hash_entry *e = ent;
875
257
  free (e->symname);
876
257
  free (e);
877
257
}
878
879
static struct comdat_hash_entry *
880
find_flags (htab_t comdat_hash, int target_index)
881
10.5k
{
882
10.5k
  struct comdat_hash_entry needle;
883
10.5k
  needle.target_index = target_index;
884
885
10.5k
  return htab_find (comdat_hash, &needle);
886
10.5k
}
pei-i386.c:find_flags
Line
Count
Source
881
420
{
882
420
  struct comdat_hash_entry needle;
883
420
  needle.target_index = target_index;
884
885
420
  return htab_find (comdat_hash, &needle);
886
420
}
pe-x86_64.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
}
pei-x86_64.c:find_flags
Line
Count
Source
881
719
{
882
719
  struct comdat_hash_entry needle;
883
719
  needle.target_index = target_index;
884
885
719
  return htab_find (comdat_hash, &needle);
886
719
}
pe-aarch64.c:find_flags
Line
Count
Source
881
637
{
882
637
  struct comdat_hash_entry needle;
883
637
  needle.target_index = target_index;
884
885
637
  return htab_find (comdat_hash, &needle);
886
637
}
pei-aarch64.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
}
pei-ia64.c:find_flags
Line
Count
Source
881
593
{
882
593
  struct comdat_hash_entry needle;
883
593
  needle.target_index = target_index;
884
885
593
  return htab_find (comdat_hash, &needle);
886
593
}
pei-loongarch64.c:find_flags
Line
Count
Source
881
713
{
882
713
  struct comdat_hash_entry needle;
883
713
  needle.target_index = target_index;
884
885
713
  return htab_find (comdat_hash, &needle);
886
713
}
pe-arm-wince.c:find_flags
Line
Count
Source
881
562
{
882
562
  struct comdat_hash_entry needle;
883
562
  needle.target_index = target_index;
884
885
562
  return htab_find (comdat_hash, &needle);
886
562
}
pe-arm.c:find_flags
Line
Count
Source
881
562
{
882
562
  struct comdat_hash_entry needle;
883
562
  needle.target_index = target_index;
884
885
562
  return htab_find (comdat_hash, &needle);
886
562
}
pe-i386.c:find_flags
Line
Count
Source
881
806
{
882
806
  struct comdat_hash_entry needle;
883
806
  needle.target_index = target_index;
884
885
806
  return htab_find (comdat_hash, &needle);
886
806
}
pe-mcore.c:find_flags
Line
Count
Source
881
379
{
882
379
  struct comdat_hash_entry needle;
883
379
  needle.target_index = target_index;
884
885
379
  return htab_find (comdat_hash, &needle);
886
379
}
pe-sh.c:find_flags
Line
Count
Source
881
705
{
882
705
  struct comdat_hash_entry needle;
883
705
  needle.target_index = target_index;
884
885
705
  return htab_find (comdat_hash, &needle);
886
705
}
pei-arm-wince.c:find_flags
Line
Count
Source
881
524
{
882
524
  struct comdat_hash_entry needle;
883
524
  needle.target_index = target_index;
884
885
524
  return htab_find (comdat_hash, &needle);
886
524
}
pei-arm.c:find_flags
Line
Count
Source
881
767
{
882
767
  struct comdat_hash_entry needle;
883
767
  needle.target_index = target_index;
884
885
767
  return htab_find (comdat_hash, &needle);
886
767
}
pei-mcore.c:find_flags
Line
Count
Source
881
659
{
882
659
  struct comdat_hash_entry needle;
883
659
  needle.target_index = target_index;
884
885
659
  return htab_find (comdat_hash, &needle);
886
659
}
pei-sh.c:find_flags
Line
Count
Source
881
399
{
882
399
  struct comdat_hash_entry needle;
883
399
  needle.target_index = target_index;
884
885
399
  return htab_find (comdat_hash, &needle);
886
399
}
887
888
static bool
889
fill_comdat_hash (bfd *abfd)
890
7.79k
{
891
7.79k
  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
7.79k
  if (! _bfd_coff_get_external_symbols (abfd))
909
4.16k
    return true;
910
911
3.62k
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
3.62k
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
3.62k
  for (struct internal_syment isym;
915
374k
       esym < esymend;
916
370k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
370k
    {
918
370k
      char buf[SYMNMLEN + 1];
919
370k
      const char *symname;
920
370k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
370k
      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
370k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
370k
      if (symname == NULL)
949
65.7k
  {
950
65.7k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
65.7k
            abfd);
952
65.7k
    continue;
953
65.7k
  }
954
955
304k
      union internal_auxent aux;
956
957
304k
      struct comdat_hash_entry needle;
958
304k
      needle.target_index = isym.n_scnum;
959
960
304k
      void **slot
961
304k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
304k
      if (slot == NULL)
963
0
  return false;
964
965
304k
      if (*slot == NULL)
966
28.7k
  {
967
28.7k
    if (isym.n_numaux == 0)
968
13.3k
      aux.x_scn.x_comdat = 0;
969
15.3k
    else
970
15.3k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
15.3k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
742
    {
974
      /* xgettext:c-format */
975
742
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
742
          " section '%s' found"),
977
742
              abfd, symname);
978
742
      continue;
979
742
    }
980
14.6k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
14.6k
            isym.n_type, isym.n_sclass, 0,
982
14.6k
            isym.n_numaux, &aux);
983
14.6k
      }
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
27.9k
    switch (aux.x_scn.x_comdat)
998
27.9k
      {
999
23
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
23
        sec_flags &= ~SEC_LINK_ONCE;
1004
23
#endif
1005
23
        break;
1006
1007
5
      case IMAGE_COMDAT_SELECT_ANY:
1008
5
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
5
        break;
1010
1011
37
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
37
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
37
        break;
1014
1015
11
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
11
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
11
        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
3
      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
3
        sec_flags &= ~SEC_LINK_ONCE;
1031
3
#endif
1032
3
        break;
1033
1034
27.9k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
27.9k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
27.9k
        break;
1038
27.9k
      }
1039
1040
27.9k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
27.9k
    if (*slot == NULL)
1042
0
      return false;
1043
27.9k
    struct comdat_hash_entry *newentry = *slot;
1044
27.9k
    newentry->sec_flags = sec_flags;
1045
27.9k
    newentry->symname = bfd_strdup (symname);
1046
27.9k
    newentry->target_index = isym.n_scnum;
1047
27.9k
    newentry->isym = isym;
1048
27.9k
    newentry->comdat_symbol = -1;
1049
27.9k
  }
1050
276k
      else
1051
276k
  {
1052
276k
    struct comdat_hash_entry *entry = *slot;
1053
1054
276k
    if (entry->comdat_symbol != -1)
1055
268k
      continue;
1056
1057
7.31k
    char *target_name = strchr (entry->symname, '$');
1058
7.31k
    if (target_name != NULL)
1059
2.38k
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
2.38k
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
1.23k
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
2.38k
        if (strcmp (target_name,
1068
2.38k
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
2.34k
    {
1070
      /* Not the name we're looking for */
1071
2.34k
      continue;
1072
2.34k
    }
1073
2.38k
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
4.97k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
4.97k
    entry->comdat_name = bfd_strdup (symname);
1082
4.97k
  }
1083
304k
    }
1084
1085
3.62k
  return true;
1086
3.62k
}
pei-i386.c:fill_comdat_hash
Line
Count
Source
890
293
{
891
293
  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
293
  if (! _bfd_coff_get_external_symbols (abfd))
909
118
    return true;
910
911
175
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
175
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
175
  for (struct internal_syment isym;
915
781
       esym < esymend;
916
606
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
606
    {
918
606
      char buf[SYMNMLEN + 1];
919
606
      const char *symname;
920
606
      flagword sec_flags = SEC_LINK_ONCE;
921
922
606
      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
606
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
606
      if (symname == NULL)
949
178
  {
950
178
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
178
            abfd);
952
178
    continue;
953
178
  }
954
955
428
      union internal_auxent aux;
956
957
428
      struct comdat_hash_entry needle;
958
428
      needle.target_index = isym.n_scnum;
959
960
428
      void **slot
961
428
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
428
      if (slot == NULL)
963
0
  return false;
964
965
428
      if (*slot == NULL)
966
168
  {
967
168
    if (isym.n_numaux == 0)
968
100
      aux.x_scn.x_comdat = 0;
969
68
    else
970
68
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
68
        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
46
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
46
            isym.n_type, isym.n_sclass, 0,
982
46
            isym.n_numaux, &aux);
983
46
      }
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
146
    switch (aux.x_scn.x_comdat)
998
146
      {
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
146
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
146
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
146
        break;
1038
146
      }
1039
1040
146
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
146
    if (*slot == NULL)
1042
0
      return false;
1043
146
    struct comdat_hash_entry *newentry = *slot;
1044
146
    newentry->sec_flags = sec_flags;
1045
146
    newentry->symname = bfd_strdup (symname);
1046
146
    newentry->target_index = isym.n_scnum;
1047
146
    newentry->isym = isym;
1048
146
    newentry->comdat_symbol = -1;
1049
146
  }
1050
260
      else
1051
260
  {
1052
260
    struct comdat_hash_entry *entry = *slot;
1053
1054
260
    if (entry->comdat_symbol != -1)
1055
227
      continue;
1056
1057
33
    char *target_name = strchr (entry->symname, '$');
1058
33
    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
33
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
33
    entry->comdat_name = bfd_strdup (symname);
1082
33
  }
1083
428
    }
1084
1085
175
  return true;
1086
175
}
pe-x86_64.c:fill_comdat_hash
Line
Count
Source
890
804
{
891
804
  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
804
  if (! _bfd_coff_get_external_symbols (abfd))
909
411
    return true;
910
911
393
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
393
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
393
  for (struct internal_syment isym;
915
4.02k
       esym < esymend;
916
3.63k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
3.63k
    {
918
3.63k
      char buf[SYMNMLEN + 1];
919
3.63k
      const char *symname;
920
3.63k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
3.63k
      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
3.63k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
3.63k
      if (symname == NULL)
949
1.24k
  {
950
1.24k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
1.24k
            abfd);
952
1.24k
    continue;
953
1.24k
  }
954
955
2.38k
      union internal_auxent aux;
956
957
2.38k
      struct comdat_hash_entry needle;
958
2.38k
      needle.target_index = isym.n_scnum;
959
960
2.38k
      void **slot
961
2.38k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
2.38k
      if (slot == NULL)
963
0
  return false;
964
965
2.38k
      if (*slot == NULL)
966
931
  {
967
931
    if (isym.n_numaux == 0)
968
539
      aux.x_scn.x_comdat = 0;
969
392
    else
970
392
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
392
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
84
    {
974
      /* xgettext:c-format */
975
84
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
84
          " section '%s' found"),
977
84
              abfd, symname);
978
84
      continue;
979
84
    }
980
308
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
308
            isym.n_type, isym.n_sclass, 0,
982
308
            isym.n_numaux, &aux);
983
308
      }
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
847
    switch (aux.x_scn.x_comdat)
998
847
      {
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
1
      case IMAGE_COMDAT_SELECT_ANY:
1008
1
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
1
        break;
1010
1011
6
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
6
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
6
        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
838
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
838
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
838
        break;
1038
847
      }
1039
1040
847
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
847
    if (*slot == NULL)
1042
0
      return false;
1043
847
    struct comdat_hash_entry *newentry = *slot;
1044
847
    newentry->sec_flags = sec_flags;
1045
847
    newentry->symname = bfd_strdup (symname);
1046
847
    newentry->target_index = isym.n_scnum;
1047
847
    newentry->isym = isym;
1048
847
    newentry->comdat_symbol = -1;
1049
847
  }
1050
1.45k
      else
1051
1.45k
  {
1052
1.45k
    struct comdat_hash_entry *entry = *slot;
1053
1054
1.45k
    if (entry->comdat_symbol != -1)
1055
1.24k
      continue;
1056
1057
202
    char *target_name = strchr (entry->symname, '$');
1058
202
    if (target_name != NULL)
1059
32
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
32
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
32
        if (strcmp (target_name,
1068
32
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
27
    {
1070
      /* Not the name we're looking for */
1071
27
      continue;
1072
27
    }
1073
32
      }
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
175
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
175
    entry->comdat_name = bfd_strdup (symname);
1082
175
  }
1083
2.38k
    }
1084
1085
393
  return true;
1086
393
}
pei-x86_64.c:fill_comdat_hash
Line
Count
Source
890
490
{
891
490
  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
490
  if (! _bfd_coff_get_external_symbols (abfd))
909
201
    return true;
910
911
289
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
289
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
289
  for (struct internal_syment isym;
915
8.67k
       esym < esymend;
916
8.38k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
8.38k
    {
918
8.38k
      char buf[SYMNMLEN + 1];
919
8.38k
      const char *symname;
920
8.38k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
8.38k
      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
8.38k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
8.38k
      if (symname == NULL)
949
2.33k
  {
950
2.33k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
2.33k
            abfd);
952
2.33k
    continue;
953
2.33k
  }
954
955
6.05k
      union internal_auxent aux;
956
957
6.05k
      struct comdat_hash_entry needle;
958
6.05k
      needle.target_index = isym.n_scnum;
959
960
6.05k
      void **slot
961
6.05k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
6.05k
      if (slot == NULL)
963
0
  return false;
964
965
6.05k
      if (*slot == NULL)
966
1.94k
  {
967
1.94k
    if (isym.n_numaux == 0)
968
809
      aux.x_scn.x_comdat = 0;
969
1.13k
    else
970
1.13k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
1.13k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
37
    {
974
      /* xgettext:c-format */
975
37
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
37
          " section '%s' found"),
977
37
              abfd, symname);
978
37
      continue;
979
37
    }
980
1.10k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
1.10k
            isym.n_type, isym.n_sclass, 0,
982
1.10k
            isym.n_numaux, &aux);
983
1.10k
      }
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
1.90k
    switch (aux.x_scn.x_comdat)
998
1.90k
      {
999
1
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
1
        sec_flags &= ~SEC_LINK_ONCE;
1004
1
#endif
1005
1
        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
1.90k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
1.90k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
1.90k
        break;
1038
1.90k
      }
1039
1040
1.90k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
1.90k
    if (*slot == NULL)
1042
0
      return false;
1043
1.90k
    struct comdat_hash_entry *newentry = *slot;
1044
1.90k
    newentry->sec_flags = sec_flags;
1045
1.90k
    newentry->symname = bfd_strdup (symname);
1046
1.90k
    newentry->target_index = isym.n_scnum;
1047
1.90k
    newentry->isym = isym;
1048
1.90k
    newentry->comdat_symbol = -1;
1049
1.90k
  }
1050
4.10k
      else
1051
4.10k
  {
1052
4.10k
    struct comdat_hash_entry *entry = *slot;
1053
1054
4.10k
    if (entry->comdat_symbol != -1)
1055
3.45k
      continue;
1056
1057
646
    char *target_name = strchr (entry->symname, '$');
1058
646
    if (target_name != NULL)
1059
342
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
342
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
342
        if (strcmp (target_name,
1068
342
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
339
    {
1070
      /* Not the name we're looking for */
1071
339
      continue;
1072
339
    }
1073
342
      }
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
307
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
307
    entry->comdat_name = bfd_strdup (symname);
1082
307
  }
1083
6.05k
    }
1084
1085
289
  return true;
1086
289
}
pe-aarch64.c:fill_comdat_hash
Line
Count
Source
890
540
{
891
540
  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
540
  if (! _bfd_coff_get_external_symbols (abfd))
909
351
    return true;
910
911
189
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
189
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
189
  for (struct internal_syment isym;
915
867
       esym < esymend;
916
678
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
678
    {
918
678
      char buf[SYMNMLEN + 1];
919
678
      const char *symname;
920
678
      flagword sec_flags = SEC_LINK_ONCE;
921
922
678
      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
678
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
678
      if (symname == NULL)
949
280
  {
950
280
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
280
            abfd);
952
280
    continue;
953
280
  }
954
955
398
      union internal_auxent aux;
956
957
398
      struct comdat_hash_entry needle;
958
398
      needle.target_index = isym.n_scnum;
959
960
398
      void **slot
961
398
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
398
      if (slot == NULL)
963
0
  return false;
964
965
398
      if (*slot == NULL)
966
205
  {
967
205
    if (isym.n_numaux == 0)
968
137
      aux.x_scn.x_comdat = 0;
969
68
    else
970
68
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
68
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
34
    {
974
      /* xgettext:c-format */
975
34
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
34
          " section '%s' found"),
977
34
              abfd, symname);
978
34
      continue;
979
34
    }
980
34
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
34
            isym.n_type, isym.n_sclass, 0,
982
34
            isym.n_numaux, &aux);
983
34
      }
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
171
    switch (aux.x_scn.x_comdat)
998
171
      {
999
1
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
1
        sec_flags &= ~SEC_LINK_ONCE;
1004
1
#endif
1005
1
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
1
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
1
        break;
1014
1015
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
169
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
169
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
169
        break;
1038
171
      }
1039
1040
171
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
171
    if (*slot == NULL)
1042
0
      return false;
1043
171
    struct comdat_hash_entry *newentry = *slot;
1044
171
    newentry->sec_flags = sec_flags;
1045
171
    newentry->symname = bfd_strdup (symname);
1046
171
    newentry->target_index = isym.n_scnum;
1047
171
    newentry->isym = isym;
1048
171
    newentry->comdat_symbol = -1;
1049
171
  }
1050
193
      else
1051
193
  {
1052
193
    struct comdat_hash_entry *entry = *slot;
1053
1054
193
    if (entry->comdat_symbol != -1)
1055
137
      continue;
1056
1057
56
    char *target_name = strchr (entry->symname, '$');
1058
56
    if (target_name != NULL)
1059
14
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
14
        target_name += 1;
1063
14
#ifndef TARGET_UNDERSCORE
1064
14
#define TARGET_UNDERSCORE 0
1065
14
#endif
1066
        /* Is this the name we're looking for ?  */
1067
14
        if (strcmp (target_name,
1068
14
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
13
    {
1070
      /* Not the name we're looking for */
1071
13
      continue;
1072
13
    }
1073
14
      }
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
43
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
43
    entry->comdat_name = bfd_strdup (symname);
1082
43
  }
1083
398
    }
1084
1085
189
  return true;
1086
189
}
pei-aarch64.c:fill_comdat_hash
Line
Count
Source
890
750
{
891
750
  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
750
  if (! _bfd_coff_get_external_symbols (abfd))
909
477
    return true;
910
911
273
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
273
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
273
  for (struct internal_syment isym;
915
264k
       esym < esymend;
916
263k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
263k
    {
918
263k
      char buf[SYMNMLEN + 1];
919
263k
      const char *symname;
920
263k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
263k
      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
263k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
263k
      if (symname == NULL)
949
28.9k
  {
950
28.9k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
28.9k
            abfd);
952
28.9k
    continue;
953
28.9k
  }
954
955
234k
      union internal_auxent aux;
956
957
234k
      struct comdat_hash_entry needle;
958
234k
      needle.target_index = isym.n_scnum;
959
960
234k
      void **slot
961
234k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
234k
      if (slot == NULL)
963
0
  return false;
964
965
234k
      if (*slot == NULL)
966
10.6k
  {
967
10.6k
    if (isym.n_numaux == 0)
968
3.64k
      aux.x_scn.x_comdat = 0;
969
7.01k
    else
970
7.01k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
7.01k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
44
    {
974
      /* xgettext:c-format */
975
44
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
44
          " section '%s' found"),
977
44
              abfd, symname);
978
44
      continue;
979
44
    }
980
6.97k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
6.97k
            isym.n_type, isym.n_sclass, 0,
982
6.97k
            isym.n_numaux, &aux);
983
6.97k
      }
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
10.6k
    switch (aux.x_scn.x_comdat)
998
10.6k
      {
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
1
      case IMAGE_COMDAT_SELECT_ANY:
1008
1
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
1
        break;
1010
1011
0
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
0
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
1
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
1
        sec_flags &= ~SEC_LINK_ONCE;
1031
1
#endif
1032
1
        break;
1033
1034
10.6k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
10.6k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
10.6k
        break;
1038
10.6k
      }
1039
1040
10.6k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
10.6k
    if (*slot == NULL)
1042
0
      return false;
1043
10.6k
    struct comdat_hash_entry *newentry = *slot;
1044
10.6k
    newentry->sec_flags = sec_flags;
1045
10.6k
    newentry->symname = bfd_strdup (symname);
1046
10.6k
    newentry->target_index = isym.n_scnum;
1047
10.6k
    newentry->isym = isym;
1048
10.6k
    newentry->comdat_symbol = -1;
1049
10.6k
  }
1050
224k
      else
1051
224k
  {
1052
224k
    struct comdat_hash_entry *entry = *slot;
1053
1054
224k
    if (entry->comdat_symbol != -1)
1055
221k
      continue;
1056
1057
2.45k
    char *target_name = strchr (entry->symname, '$');
1058
2.45k
    if (target_name != NULL)
1059
487
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
487
        target_name += 1;
1063
487
#ifndef TARGET_UNDERSCORE
1064
487
#define TARGET_UNDERSCORE 0
1065
487
#endif
1066
        /* Is this the name we're looking for ?  */
1067
487
        if (strcmp (target_name,
1068
487
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
478
    {
1070
      /* Not the name we're looking for */
1071
478
      continue;
1072
478
    }
1073
487
      }
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.98k
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
1.98k
    entry->comdat_name = bfd_strdup (symname);
1082
1.98k
  }
1083
234k
    }
1084
1085
273
  return true;
1086
273
}
pei-ia64.c:fill_comdat_hash
Line
Count
Source
890
446
{
891
446
  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
446
  if (! _bfd_coff_get_external_symbols (abfd))
909
266
    return true;
910
911
180
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
180
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
180
  for (struct internal_syment isym;
915
10.3k
       esym < esymend;
916
10.1k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
10.1k
    {
918
10.1k
      char buf[SYMNMLEN + 1];
919
10.1k
      const char *symname;
920
10.1k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
10.1k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
10.1k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
10.1k
      if (symname == NULL)
949
3.44k
  {
950
3.44k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
3.44k
            abfd);
952
3.44k
    continue;
953
3.44k
  }
954
955
6.69k
      union internal_auxent aux;
956
957
6.69k
      struct comdat_hash_entry needle;
958
6.69k
      needle.target_index = isym.n_scnum;
959
960
6.69k
      void **slot
961
6.69k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
6.69k
      if (slot == NULL)
963
0
  return false;
964
965
6.69k
      if (*slot == NULL)
966
1.14k
  {
967
1.14k
    if (isym.n_numaux == 0)
968
530
      aux.x_scn.x_comdat = 0;
969
612
    else
970
612
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
612
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
46
    {
974
      /* xgettext:c-format */
975
46
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
46
          " section '%s' found"),
977
46
              abfd, symname);
978
46
      continue;
979
46
    }
980
566
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
566
            isym.n_type, isym.n_sclass, 0,
982
566
            isym.n_numaux, &aux);
983
566
      }
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
1.09k
    switch (aux.x_scn.x_comdat)
998
1.09k
      {
999
0
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
0
        sec_flags &= ~SEC_LINK_ONCE;
1004
0
#endif
1005
0
        break;
1006
1007
1
      case IMAGE_COMDAT_SELECT_ANY:
1008
1
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
1
        break;
1010
1011
1
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
1
        break;
1014
1015
1
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
1
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
1.09k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
1.09k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
1.09k
        break;
1038
1.09k
      }
1039
1040
1.09k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
1.09k
    if (*slot == NULL)
1042
0
      return false;
1043
1.09k
    struct comdat_hash_entry *newentry = *slot;
1044
1.09k
    newentry->sec_flags = sec_flags;
1045
1.09k
    newentry->symname = bfd_strdup (symname);
1046
1.09k
    newentry->target_index = isym.n_scnum;
1047
1.09k
    newentry->isym = isym;
1048
1.09k
    newentry->comdat_symbol = -1;
1049
1.09k
  }
1050
5.54k
      else
1051
5.54k
  {
1052
5.54k
    struct comdat_hash_entry *entry = *slot;
1053
1054
5.54k
    if (entry->comdat_symbol != -1)
1055
4.76k
      continue;
1056
1057
782
    char *target_name = strchr (entry->symname, '$');
1058
782
    if (target_name != NULL)
1059
584
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
584
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
584
        if (strcmp (target_name,
1068
584
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
583
    {
1070
      /* Not the name we're looking for */
1071
583
      continue;
1072
583
    }
1073
584
      }
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
199
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
199
    entry->comdat_name = bfd_strdup (symname);
1082
199
  }
1083
6.69k
    }
1084
1085
180
  return true;
1086
180
}
pei-loongarch64.c:fill_comdat_hash
Line
Count
Source
890
383
{
891
383
  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
383
  if (! _bfd_coff_get_external_symbols (abfd))
909
160
    return true;
910
911
223
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
223
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
223
  for (struct internal_syment isym;
915
33.0k
       esym < esymend;
916
32.8k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
32.8k
    {
918
32.8k
      char buf[SYMNMLEN + 1];
919
32.8k
      const char *symname;
920
32.8k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
32.8k
      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
32.8k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
32.8k
      if (symname == NULL)
949
12.5k
  {
950
12.5k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
12.5k
            abfd);
952
12.5k
    continue;
953
12.5k
  }
954
955
20.2k
      union internal_auxent aux;
956
957
20.2k
      struct comdat_hash_entry needle;
958
20.2k
      needle.target_index = isym.n_scnum;
959
960
20.2k
      void **slot
961
20.2k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
20.2k
      if (slot == NULL)
963
0
  return false;
964
965
20.2k
      if (*slot == NULL)
966
4.39k
  {
967
4.39k
    if (isym.n_numaux == 0)
968
2.41k
      aux.x_scn.x_comdat = 0;
969
1.97k
    else
970
1.97k
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
1.97k
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
78
    {
974
      /* xgettext:c-format */
975
78
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
78
          " section '%s' found"),
977
78
              abfd, symname);
978
78
      continue;
979
78
    }
980
1.90k
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
1.90k
            isym.n_type, isym.n_sclass, 0,
982
1.90k
            isym.n_numaux, &aux);
983
1.90k
      }
984
985
    /* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but
986
       gnu uses ANY and SAME_SIZE.  Unfortunately, gnu doesn't
987
       do the comdat symbols right.  So, until we can fix it to
988
       do the right thing, we are temporarily disabling comdats
989
       for the MS types (they're used in DLLs and C++, but we
990
       don't support *their* C++ libraries anyway - DJ.  */
991
992
    /* Cygwin does not follow the MS style, and uses ANY and
993
       SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be
994
       used.  For Interix, we just do the right thing up
995
       front.  */
996
997
4.32k
    switch (aux.x_scn.x_comdat)
998
4.32k
      {
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
13
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
13
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
13
        break;
1014
1015
0
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
0
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
0
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
1
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
1
        sec_flags &= ~SEC_LINK_ONCE;
1031
1
#endif
1032
1
        break;
1033
1034
4.30k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
4.30k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
4.30k
        break;
1038
4.32k
      }
1039
1040
4.32k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
4.32k
    if (*slot == NULL)
1042
0
      return false;
1043
4.32k
    struct comdat_hash_entry *newentry = *slot;
1044
4.32k
    newentry->sec_flags = sec_flags;
1045
4.32k
    newentry->symname = bfd_strdup (symname);
1046
4.32k
    newentry->target_index = isym.n_scnum;
1047
4.32k
    newentry->isym = isym;
1048
4.32k
    newentry->comdat_symbol = -1;
1049
4.32k
  }
1050
15.8k
      else
1051
15.8k
  {
1052
15.8k
    struct comdat_hash_entry *entry = *slot;
1053
1054
15.8k
    if (entry->comdat_symbol != -1)
1055
14.7k
      continue;
1056
1057
1.15k
    char *target_name = strchr (entry->symname, '$');
1058
1.15k
    if (target_name != NULL)
1059
380
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
380
        target_name += 1;
1063
380
#ifndef TARGET_UNDERSCORE
1064
380
#define TARGET_UNDERSCORE 0
1065
380
#endif
1066
        /* Is this the name we're looking for ?  */
1067
380
        if (strcmp (target_name,
1068
380
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
377
    {
1070
      /* Not the name we're looking for */
1071
377
      continue;
1072
377
    }
1073
380
      }
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
773
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
773
    entry->comdat_name = bfd_strdup (symname);
1082
773
  }
1083
20.2k
    }
1084
1085
223
  return true;
1086
223
}
pe-arm-wince.c:fill_comdat_hash
Line
Count
Source
890
436
{
891
436
  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
436
  if (! _bfd_coff_get_external_symbols (abfd))
909
204
    return true;
910
911
232
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
232
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
232
  for (struct internal_syment isym;
915
7.39k
       esym < esymend;
916
7.16k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
7.16k
    {
918
7.16k
      char buf[SYMNMLEN + 1];
919
7.16k
      const char *symname;
920
7.16k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
7.16k
      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
7.16k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
7.16k
      if (symname == NULL)
949
2.43k
  {
950
2.43k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
2.43k
            abfd);
952
2.43k
    continue;
953
2.43k
  }
954
955
4.73k
      union internal_auxent aux;
956
957
4.73k
      struct comdat_hash_entry needle;
958
4.73k
      needle.target_index = isym.n_scnum;
959
960
4.73k
      void **slot
961
4.73k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
4.73k
      if (slot == NULL)
963
0
  return false;
964
965
4.73k
      if (*slot == NULL)
966
1.24k
  {
967
1.24k
    if (isym.n_numaux == 0)
968
903
      aux.x_scn.x_comdat = 0;
969
343
    else
970
343
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
343
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
62
    {
974
      /* xgettext:c-format */
975
62
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
62
          " section '%s' found"),
977
62
              abfd, symname);
978
62
      continue;
979
62
    }
980
281
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
281
            isym.n_type, isym.n_sclass, 0,
982
281
            isym.n_numaux, &aux);
983
281
      }
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
1.18k
    switch (aux.x_scn.x_comdat)
998
1.18k
      {
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
3
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
3
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
3
        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
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
1.17k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
1.17k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
1.17k
        break;
1038
1.18k
      }
1039
1040
1.18k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
1.18k
    if (*slot == NULL)
1042
0
      return false;
1043
1.18k
    struct comdat_hash_entry *newentry = *slot;
1044
1.18k
    newentry->sec_flags = sec_flags;
1045
1.18k
    newentry->symname = bfd_strdup (symname);
1046
1.18k
    newentry->target_index = isym.n_scnum;
1047
1.18k
    newentry->isym = isym;
1048
1.18k
    newentry->comdat_symbol = -1;
1049
1.18k
  }
1050
3.48k
      else
1051
3.48k
  {
1052
3.48k
    struct comdat_hash_entry *entry = *slot;
1053
1054
3.48k
    if (entry->comdat_symbol != -1)
1055
3.28k
      continue;
1056
1057
204
    char *target_name = strchr (entry->symname, '$');
1058
204
    if (target_name != NULL)
1059
19
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
19
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
19
        if (strcmp (target_name,
1068
19
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
18
    {
1070
      /* Not the name we're looking for */
1071
18
      continue;
1072
18
    }
1073
19
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
186
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
186
    entry->comdat_name = bfd_strdup (symname);
1082
186
  }
1083
4.73k
    }
1084
1085
232
  return true;
1086
232
}
pe-arm.c:fill_comdat_hash
Line
Count
Source
890
436
{
891
436
  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
436
  if (! _bfd_coff_get_external_symbols (abfd))
909
204
    return true;
910
911
232
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
232
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
232
  for (struct internal_syment isym;
915
7.39k
       esym < esymend;
916
7.16k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
7.16k
    {
918
7.16k
      char buf[SYMNMLEN + 1];
919
7.16k
      const char *symname;
920
7.16k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
7.16k
      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
7.16k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
7.16k
      if (symname == NULL)
949
2.43k
  {
950
2.43k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
2.43k
            abfd);
952
2.43k
    continue;
953
2.43k
  }
954
955
4.73k
      union internal_auxent aux;
956
957
4.73k
      struct comdat_hash_entry needle;
958
4.73k
      needle.target_index = isym.n_scnum;
959
960
4.73k
      void **slot
961
4.73k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
4.73k
      if (slot == NULL)
963
0
  return false;
964
965
4.73k
      if (*slot == NULL)
966
1.24k
  {
967
1.24k
    if (isym.n_numaux == 0)
968
903
      aux.x_scn.x_comdat = 0;
969
343
    else
970
343
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
343
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
62
    {
974
      /* xgettext:c-format */
975
62
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
62
          " section '%s' found"),
977
62
              abfd, symname);
978
62
      continue;
979
62
    }
980
281
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
281
            isym.n_type, isym.n_sclass, 0,
982
281
            isym.n_numaux, &aux);
983
281
      }
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
1.18k
    switch (aux.x_scn.x_comdat)
998
1.18k
      {
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
3
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
3
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
3
        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
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
1.17k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
1.17k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
1.17k
        break;
1038
1.18k
      }
1039
1040
1.18k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
1.18k
    if (*slot == NULL)
1042
0
      return false;
1043
1.18k
    struct comdat_hash_entry *newentry = *slot;
1044
1.18k
    newentry->sec_flags = sec_flags;
1045
1.18k
    newentry->symname = bfd_strdup (symname);
1046
1.18k
    newentry->target_index = isym.n_scnum;
1047
1.18k
    newentry->isym = isym;
1048
1.18k
    newentry->comdat_symbol = -1;
1049
1.18k
  }
1050
3.48k
      else
1051
3.48k
  {
1052
3.48k
    struct comdat_hash_entry *entry = *slot;
1053
1054
3.48k
    if (entry->comdat_symbol != -1)
1055
3.28k
      continue;
1056
1057
204
    char *target_name = strchr (entry->symname, '$');
1058
204
    if (target_name != NULL)
1059
19
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
19
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
19
        if (strcmp (target_name,
1068
19
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
18
    {
1070
      /* Not the name we're looking for */
1071
18
      continue;
1072
18
    }
1073
19
      }
1074
    /* MSVC mode: the lexically second symbol (or drop through
1075
       from the above).  */
1076
    /* This must the second symbol with the section #.  It is
1077
       the actual symbol name.  Intel puts the two adjacent, but
1078
       Alpha (at least) spreads them out.  */
1079
1080
186
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
186
    entry->comdat_name = bfd_strdup (symname);
1082
186
  }
1083
4.73k
    }
1084
1085
232
  return true;
1086
232
}
pe-i386.c:fill_comdat_hash
Line
Count
Source
890
645
{
891
645
  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
645
  if (! _bfd_coff_get_external_symbols (abfd))
909
376
    return true;
910
911
269
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
269
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
269
  for (struct internal_syment isym;
915
3.16k
       esym < esymend;
916
2.89k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
2.89k
    {
918
2.89k
      char buf[SYMNMLEN + 1];
919
2.89k
      const char *symname;
920
2.89k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
2.89k
      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
2.89k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
2.89k
      if (symname == NULL)
949
955
  {
950
955
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
955
            abfd);
952
955
    continue;
953
955
  }
954
955
1.93k
      union internal_auxent aux;
956
957
1.93k
      struct comdat_hash_entry needle;
958
1.93k
      needle.target_index = isym.n_scnum;
959
960
1.93k
      void **slot
961
1.93k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
1.93k
      if (slot == NULL)
963
0
  return false;
964
965
1.93k
      if (*slot == NULL)
966
713
  {
967
713
    if (isym.n_numaux == 0)
968
410
      aux.x_scn.x_comdat = 0;
969
303
    else
970
303
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
303
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
60
    {
974
      /* xgettext:c-format */
975
60
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
60
          " section '%s' found"),
977
60
              abfd, symname);
978
60
      continue;
979
60
    }
980
243
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
243
            isym.n_type, isym.n_sclass, 0,
982
243
            isym.n_numaux, &aux);
983
243
      }
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
653
    switch (aux.x_scn.x_comdat)
998
653
      {
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
653
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
653
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
653
        break;
1038
653
      }
1039
1040
653
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
653
    if (*slot == NULL)
1042
0
      return false;
1043
653
    struct comdat_hash_entry *newentry = *slot;
1044
653
    newentry->sec_flags = sec_flags;
1045
653
    newentry->symname = bfd_strdup (symname);
1046
653
    newentry->target_index = isym.n_scnum;
1047
653
    newentry->isym = isym;
1048
653
    newentry->comdat_symbol = -1;
1049
653
  }
1050
1.22k
      else
1051
1.22k
  {
1052
1.22k
    struct comdat_hash_entry *entry = *slot;
1053
1054
1.22k
    if (entry->comdat_symbol != -1)
1055
1.08k
      continue;
1056
1057
137
    char *target_name = strchr (entry->symname, '$');
1058
137
    if (target_name != NULL)
1059
43
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
43
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
43
        if (strcmp (target_name,
1068
43
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
42
    {
1070
      /* Not the name we're looking for */
1071
42
      continue;
1072
42
    }
1073
43
      }
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
95
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
95
    entry->comdat_name = bfd_strdup (symname);
1082
95
  }
1083
1.93k
    }
1084
1085
269
  return true;
1086
269
}
pe-mcore.c:fill_comdat_hash
Line
Count
Source
890
328
{
891
328
  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
328
  if (! _bfd_coff_get_external_symbols (abfd))
909
177
    return true;
910
911
151
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
151
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
151
  for (struct internal_syment isym;
915
4.37k
       esym < esymend;
916
4.22k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
4.22k
    {
918
4.22k
      char buf[SYMNMLEN + 1];
919
4.22k
      const char *symname;
920
4.22k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
4.22k
      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
4.22k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
4.22k
      if (symname == NULL)
949
1.21k
  {
950
1.21k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
1.21k
            abfd);
952
1.21k
    continue;
953
1.21k
  }
954
955
3.00k
      union internal_auxent aux;
956
957
3.00k
      struct comdat_hash_entry needle;
958
3.00k
      needle.target_index = isym.n_scnum;
959
960
3.00k
      void **slot
961
3.00k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
3.00k
      if (slot == NULL)
963
0
  return false;
964
965
3.00k
      if (*slot == NULL)
966
736
  {
967
736
    if (isym.n_numaux == 0)
968
514
      aux.x_scn.x_comdat = 0;
969
222
    else
970
222
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
222
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
29
    {
974
      /* xgettext:c-format */
975
29
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
29
          " section '%s' found"),
977
29
              abfd, symname);
978
29
      continue;
979
29
    }
980
193
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
193
            isym.n_type, isym.n_sclass, 0,
982
193
            isym.n_numaux, &aux);
983
193
      }
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
707
    switch (aux.x_scn.x_comdat)
998
707
      {
999
1
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
1
        sec_flags &= ~SEC_LINK_ONCE;
1004
1
#endif
1005
1
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
1
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
1
        break;
1014
1015
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
705
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
705
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
705
        break;
1038
707
      }
1039
1040
707
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
707
    if (*slot == NULL)
1042
0
      return false;
1043
707
    struct comdat_hash_entry *newentry = *slot;
1044
707
    newentry->sec_flags = sec_flags;
1045
707
    newentry->symname = bfd_strdup (symname);
1046
707
    newentry->target_index = isym.n_scnum;
1047
707
    newentry->isym = isym;
1048
707
    newentry->comdat_symbol = -1;
1049
707
  }
1050
2.27k
      else
1051
2.27k
  {
1052
2.27k
    struct comdat_hash_entry *entry = *slot;
1053
1054
2.27k
    if (entry->comdat_symbol != -1)
1055
1.78k
      continue;
1056
1057
484
    char *target_name = strchr (entry->symname, '$');
1058
484
    if (target_name != NULL)
1059
339
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
339
        target_name += 1;
1063
339
#ifndef TARGET_UNDERSCORE
1064
339
#define TARGET_UNDERSCORE 0
1065
339
#endif
1066
        /* Is this the name we're looking for ?  */
1067
339
        if (strcmp (target_name,
1068
339
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
338
    {
1070
      /* Not the name we're looking for */
1071
338
      continue;
1072
338
    }
1073
339
      }
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
146
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
146
    entry->comdat_name = bfd_strdup (symname);
1082
146
  }
1083
3.00k
    }
1084
1085
151
  return true;
1086
151
}
pe-sh.c:fill_comdat_hash
Line
Count
Source
890
535
{
891
535
  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
535
  if (! _bfd_coff_get_external_symbols (abfd))
909
236
    return true;
910
911
299
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
299
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
299
  for (struct internal_syment isym;
915
16.0k
       esym < esymend;
916
15.7k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
15.7k
    {
918
15.7k
      char buf[SYMNMLEN + 1];
919
15.7k
      const char *symname;
920
15.7k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
15.7k
      bfd_coff_swap_sym_in (abfd, esym, &isym);
923
924
      /* According to the MSVC documentation, the first TWO entries
925
   with the section # are both of interest to us.  The first one
926
   is the "section symbol" (section name).  The second is the
927
   comdat symbol name.  Here, we've found the first qualifying
928
   entry; we distinguish it from the second with a state flag.
929
930
   In the case of gas-generated (at least until that is fixed)
931
   .o files, it isn't necessarily the second one.  It may be
932
   some other later symbol.
933
934
   Since gas also doesn't follow MS conventions and emits the
935
   section similar to .text$<name>, where <something> is the
936
   name we're looking for, we distinguish the two as follows:
937
938
   If the section name is simply a section name (no $) we
939
   presume it's MS-generated, and look at precisely the second
940
   symbol for the comdat name.  If the section name has a $, we
941
   assume it's gas-generated, and look for <something> (whatever
942
   follows the $) as the comdat symbol.  */
943
944
      /* All 3 branches use this.  */
945
15.7k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
15.7k
      if (symname == NULL)
949
6.11k
  {
950
6.11k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
6.11k
            abfd);
952
6.11k
    continue;
953
6.11k
  }
954
955
9.62k
      union internal_auxent aux;
956
957
9.62k
      struct comdat_hash_entry needle;
958
9.62k
      needle.target_index = isym.n_scnum;
959
960
9.62k
      void **slot
961
9.62k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
9.62k
      if (slot == NULL)
963
0
  return false;
964
965
9.62k
      if (*slot == NULL)
966
1.83k
  {
967
1.83k
    if (isym.n_numaux == 0)
968
1.06k
      aux.x_scn.x_comdat = 0;
969
779
    else
970
779
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
779
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
33
    {
974
      /* xgettext:c-format */
975
33
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
33
          " section '%s' found"),
977
33
              abfd, symname);
978
33
      continue;
979
33
    }
980
746
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
746
            isym.n_type, isym.n_sclass, 0,
982
746
            isym.n_numaux, &aux);
983
746
      }
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
1.80k
    switch (aux.x_scn.x_comdat)
998
1.80k
      {
999
8
      case IMAGE_COMDAT_SELECT_NODUPLICATES:
1000
#ifdef STRICT_PE_FORMAT
1001
        sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1002
#else
1003
8
        sec_flags &= ~SEC_LINK_ONCE;
1004
8
#endif
1005
8
        break;
1006
1007
0
      case IMAGE_COMDAT_SELECT_ANY:
1008
0
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
0
        break;
1010
1011
5
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
5
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
5
        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
1
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
1
        sec_flags &= ~SEC_LINK_ONCE;
1031
1
#endif
1032
1
        break;
1033
1034
1.79k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
1.79k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
1.79k
        break;
1038
1.80k
      }
1039
1040
1.80k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
1.80k
    if (*slot == NULL)
1042
0
      return false;
1043
1.80k
    struct comdat_hash_entry *newentry = *slot;
1044
1.80k
    newentry->sec_flags = sec_flags;
1045
1.80k
    newentry->symname = bfd_strdup (symname);
1046
1.80k
    newentry->target_index = isym.n_scnum;
1047
1.80k
    newentry->isym = isym;
1048
1.80k
    newentry->comdat_symbol = -1;
1049
1.80k
  }
1050
7.78k
      else
1051
7.78k
  {
1052
7.78k
    struct comdat_hash_entry *entry = *slot;
1053
1054
7.78k
    if (entry->comdat_symbol != -1)
1055
7.28k
      continue;
1056
1057
505
    char *target_name = strchr (entry->symname, '$');
1058
505
    if (target_name != NULL)
1059
85
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
85
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
85
        if (strcmp (target_name,
1068
85
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
74
    {
1070
      /* Not the name we're looking for */
1071
74
      continue;
1072
74
    }
1073
85
      }
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
431
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
431
    entry->comdat_name = bfd_strdup (symname);
1082
431
  }
1083
9.62k
    }
1084
1085
299
  return true;
1086
299
}
pei-arm-wince.c:fill_comdat_hash
Line
Count
Source
890
445
{
891
445
  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
445
  if (! _bfd_coff_get_external_symbols (abfd))
909
259
    return true;
910
911
186
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
186
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
186
  for (struct internal_syment isym;
915
3.79k
       esym < esymend;
916
3.60k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
3.60k
    {
918
3.60k
      char buf[SYMNMLEN + 1];
919
3.60k
      const char *symname;
920
3.60k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
3.60k
      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
3.60k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
3.60k
      if (symname == NULL)
949
990
  {
950
990
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
990
            abfd);
952
990
    continue;
953
990
  }
954
955
2.61k
      union internal_auxent aux;
956
957
2.61k
      struct comdat_hash_entry needle;
958
2.61k
      needle.target_index = isym.n_scnum;
959
960
2.61k
      void **slot
961
2.61k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
2.61k
      if (slot == NULL)
963
0
  return false;
964
965
2.61k
      if (*slot == NULL)
966
1.23k
  {
967
1.23k
    if (isym.n_numaux == 0)
968
375
      aux.x_scn.x_comdat = 0;
969
860
    else
970
860
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
860
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
42
    {
974
      /* xgettext:c-format */
975
42
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
42
          " section '%s' found"),
977
42
              abfd, symname);
978
42
      continue;
979
42
    }
980
818
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
818
            isym.n_type, isym.n_sclass, 0,
982
818
            isym.n_numaux, &aux);
983
818
      }
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
1.19k
    switch (aux.x_scn.x_comdat)
998
1.19k
      {
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
1
      case IMAGE_COMDAT_SELECT_ANY:
1008
1
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
1
        break;
1010
1011
2
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
2
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
2
        break;
1014
1015
1
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
1
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
1.18k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
1.18k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
1.18k
        break;
1038
1.19k
      }
1039
1040
1.19k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
1.19k
    if (*slot == NULL)
1042
0
      return false;
1043
1.19k
    struct comdat_hash_entry *newentry = *slot;
1044
1.19k
    newentry->sec_flags = sec_flags;
1045
1.19k
    newentry->symname = bfd_strdup (symname);
1046
1.19k
    newentry->target_index = isym.n_scnum;
1047
1.19k
    newentry->isym = isym;
1048
1.19k
    newentry->comdat_symbol = -1;
1049
1.19k
  }
1050
1.38k
      else
1051
1.38k
  {
1052
1.38k
    struct comdat_hash_entry *entry = *slot;
1053
1054
1.38k
    if (entry->comdat_symbol != -1)
1055
1.25k
      continue;
1056
1057
125
    char *target_name = strchr (entry->symname, '$');
1058
125
    if (target_name != NULL)
1059
12
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
12
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
12
        if (strcmp (target_name,
1068
12
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
12
    {
1070
      /* Not the name we're looking for */
1071
12
      continue;
1072
12
    }
1073
12
      }
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
113
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
113
    entry->comdat_name = bfd_strdup (symname);
1082
113
  }
1083
2.61k
    }
1084
1085
186
  return true;
1086
186
}
pei-arm.c:fill_comdat_hash
Line
Count
Source
890
614
{
891
614
  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
614
  if (! _bfd_coff_get_external_symbols (abfd))
909
354
    return true;
910
911
260
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
260
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
260
  for (struct internal_syment isym;
915
4.07k
       esym < esymend;
916
3.81k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
3.81k
    {
918
3.81k
      char buf[SYMNMLEN + 1];
919
3.81k
      const char *symname;
920
3.81k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
3.81k
      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
3.81k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
3.81k
      if (symname == NULL)
949
1.06k
  {
950
1.06k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
1.06k
            abfd);
952
1.06k
    continue;
953
1.06k
  }
954
955
2.75k
      union internal_auxent aux;
956
957
2.75k
      struct comdat_hash_entry needle;
958
2.75k
      needle.target_index = isym.n_scnum;
959
960
2.75k
      void **slot
961
2.75k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
2.75k
      if (slot == NULL)
963
0
  return false;
964
965
2.75k
      if (*slot == NULL)
966
1.29k
  {
967
1.29k
    if (isym.n_numaux == 0)
968
408
      aux.x_scn.x_comdat = 0;
969
889
    else
970
889
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
889
        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
841
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
841
            isym.n_type, isym.n_sclass, 0,
982
841
            isym.n_numaux, &aux);
983
841
      }
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
1.24k
    switch (aux.x_scn.x_comdat)
998
1.24k
      {
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
1
      case IMAGE_COMDAT_SELECT_ANY:
1008
1
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1009
1
        break;
1010
1011
2
      case IMAGE_COMDAT_SELECT_SAME_SIZE:
1012
2
        sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1013
2
        break;
1014
1015
1
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
1
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
1.24k
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
1.24k
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
1.24k
        break;
1038
1.24k
      }
1039
1040
1.24k
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
1.24k
    if (*slot == NULL)
1042
0
      return false;
1043
1.24k
    struct comdat_hash_entry *newentry = *slot;
1044
1.24k
    newentry->sec_flags = sec_flags;
1045
1.24k
    newentry->symname = bfd_strdup (symname);
1046
1.24k
    newentry->target_index = isym.n_scnum;
1047
1.24k
    newentry->isym = isym;
1048
1.24k
    newentry->comdat_symbol = -1;
1049
1.24k
  }
1050
1.45k
      else
1051
1.45k
  {
1052
1.45k
    struct comdat_hash_entry *entry = *slot;
1053
1054
1.45k
    if (entry->comdat_symbol != -1)
1055
1.31k
      continue;
1056
1057
139
    char *target_name = strchr (entry->symname, '$');
1058
139
    if (target_name != NULL)
1059
12
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
12
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#endif
1066
        /* Is this the name we're looking for ?  */
1067
12
        if (strcmp (target_name,
1068
12
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
12
    {
1070
      /* Not the name we're looking for */
1071
12
      continue;
1072
12
    }
1073
12
      }
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
127
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
127
    entry->comdat_name = bfd_strdup (symname);
1082
127
  }
1083
2.75k
    }
1084
1085
260
  return true;
1086
260
}
pei-mcore.c:fill_comdat_hash
Line
Count
Source
890
345
{
891
345
  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
345
  if (! _bfd_coff_get_external_symbols (abfd))
909
231
    return true;
910
911
114
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
114
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
114
  for (struct internal_syment isym;
915
4.35k
       esym < esymend;
916
4.24k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
4.24k
    {
918
4.24k
      char buf[SYMNMLEN + 1];
919
4.24k
      const char *symname;
920
4.24k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
4.24k
      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
4.24k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
4.24k
      if (symname == NULL)
949
1.12k
  {
950
1.12k
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
1.12k
            abfd);
952
1.12k
    continue;
953
1.12k
  }
954
955
3.12k
      union internal_auxent aux;
956
957
3.12k
      struct comdat_hash_entry needle;
958
3.12k
      needle.target_index = isym.n_scnum;
959
960
3.12k
      void **slot
961
3.12k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
3.12k
      if (slot == NULL)
963
0
  return false;
964
965
3.12k
      if (*slot == NULL)
966
696
  {
967
696
    if (isym.n_numaux == 0)
968
467
      aux.x_scn.x_comdat = 0;
969
229
    else
970
229
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
229
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
40
    {
974
      /* xgettext:c-format */
975
40
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
40
          " section '%s' found"),
977
40
              abfd, symname);
978
40
      continue;
979
40
    }
980
189
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
189
            isym.n_type, isym.n_sclass, 0,
982
189
            isym.n_numaux, &aux);
983
189
      }
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
656
    switch (aux.x_scn.x_comdat)
998
656
      {
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
1
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
1
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
655
      default:  /* 0 means "no symbol" */
1035
        /* debug$F gets this case; other implications ???  */
1036
655
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1037
655
        break;
1038
656
      }
1039
1040
656
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
656
    if (*slot == NULL)
1042
0
      return false;
1043
656
    struct comdat_hash_entry *newentry = *slot;
1044
656
    newentry->sec_flags = sec_flags;
1045
656
    newentry->symname = bfd_strdup (symname);
1046
656
    newentry->target_index = isym.n_scnum;
1047
656
    newentry->isym = isym;
1048
656
    newentry->comdat_symbol = -1;
1049
656
  }
1050
2.42k
      else
1051
2.42k
  {
1052
2.42k
    struct comdat_hash_entry *entry = *slot;
1053
1054
2.42k
    if (entry->comdat_symbol != -1)
1055
2.28k
      continue;
1056
1057
139
    char *target_name = strchr (entry->symname, '$');
1058
139
    if (target_name != NULL)
1059
12
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
12
        target_name += 1;
1063
12
#ifndef TARGET_UNDERSCORE
1064
12
#define TARGET_UNDERSCORE 0
1065
12
#endif
1066
        /* Is this the name we're looking for ?  */
1067
12
        if (strcmp (target_name,
1068
12
        symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
1069
10
    {
1070
      /* Not the name we're looking for */
1071
10
      continue;
1072
10
    }
1073
12
      }
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
129
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
129
    entry->comdat_name = bfd_strdup (symname);
1082
129
  }
1083
3.12k
    }
1084
1085
114
  return true;
1086
114
}
pei-sh.c:fill_comdat_hash
Line
Count
Source
890
302
{
891
302
  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
302
  if (! _bfd_coff_get_external_symbols (abfd))
909
139
    return true;
910
911
163
  esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
912
163
  esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
913
914
163
  for (struct internal_syment isym;
915
1.74k
       esym < esymend;
916
1.58k
       esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd))
917
1.58k
    {
918
1.58k
      char buf[SYMNMLEN + 1];
919
1.58k
      const char *symname;
920
1.58k
      flagword sec_flags = SEC_LINK_ONCE;
921
922
1.58k
      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.58k
      symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
946
947
      /* PR 17512 file: 078-11867-0.004  */
948
1.58k
      if (symname == NULL)
949
434
  {
950
434
    _bfd_error_handler (_("%pB: unable to load COMDAT section name"),
951
434
            abfd);
952
434
    continue;
953
434
  }
954
955
1.14k
      union internal_auxent aux;
956
957
1.14k
      struct comdat_hash_entry needle;
958
1.14k
      needle.target_index = isym.n_scnum;
959
960
1.14k
      void **slot
961
1.14k
  = htab_find_slot (pe_data (abfd)->comdat_hash, &needle, INSERT);
962
1.14k
      if (slot == NULL)
963
0
  return false;
964
965
1.14k
      if (*slot == NULL)
966
278
  {
967
278
    if (isym.n_numaux == 0)
968
137
      aux.x_scn.x_comdat = 0;
969
141
    else
970
141
      {
971
        /* PR 17512: file: e2cfe54f.  */
972
141
        if (esym + isym.n_numaux * bfd_coff_symesz (abfd) >= esymend)
973
21
    {
974
      /* xgettext:c-format */
975
21
      _bfd_error_handler (_("%pB: warning: no symbol for"
976
21
          " section '%s' found"),
977
21
              abfd, symname);
978
21
      continue;
979
21
    }
980
120
        bfd_coff_swap_aux_in (abfd, (esym + bfd_coff_symesz (abfd)),
981
120
            isym.n_type, isym.n_sclass, 0,
982
120
            isym.n_numaux, &aux);
983
120
      }
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
257
    switch (aux.x_scn.x_comdat)
998
257
      {
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
1
      case IMAGE_COMDAT_SELECT_EXACT_MATCH:
1016
        /* Not yet fully implemented ??? */
1017
1
        sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1018
1
        break;
1019
1020
        /* debug$S gets this case; other implications ???  */
1021
1022
        /* There may be no symbol.  We'll search the whole
1023
     table.  Is this the right place to play this game?
1024
     Or should we do it when reading it in?  */
1025
0
      case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
1026
#ifdef STRICT_PE_FORMAT
1027
        /* FIXME: This is not currently implemented.  */
1028
        sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
1029
#else
1030
0
        sec_flags &= ~SEC_LINK_ONCE;
1031
0
#endif
1032
0
        break;
1033
1034
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
257
      }
1039
1040
257
    *slot = bfd_zmalloc (sizeof (struct comdat_hash_entry));
1041
257
    if (*slot == NULL)
1042
0
      return false;
1043
257
    struct comdat_hash_entry *newentry = *slot;
1044
257
    newentry->sec_flags = sec_flags;
1045
257
    newentry->symname = bfd_strdup (symname);
1046
257
    newentry->target_index = isym.n_scnum;
1047
257
    newentry->isym = isym;
1048
257
    newentry->comdat_symbol = -1;
1049
257
  }
1050
869
      else
1051
869
  {
1052
869
    struct comdat_hash_entry *entry = *slot;
1053
1054
869
    if (entry->comdat_symbol != -1)
1055
817
      continue;
1056
1057
52
    char *target_name = strchr (entry->symname, '$');
1058
52
    if (target_name != NULL)
1059
2
      {
1060
        /* Gas mode: the first matching on partial name.  */
1061
1062
2
        target_name += 1;
1063
#ifndef TARGET_UNDERSCORE
1064
#define TARGET_UNDERSCORE 0
1065
#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
1
    {
1070
      /* Not the name we're looking for */
1071
1
      continue;
1072
1
    }
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
51
    entry->comdat_symbol = (esym - esymstart) / bfd_coff_symesz (abfd);
1081
51
    entry->comdat_name = bfd_strdup (symname);
1082
51
  }
1083
1.14k
    }
1084
1085
163
  return true;
1086
163
}
1087
1088
static bool
1089
insert_coff_comdat_info (bfd *abfd, asection *section, const char *symname,
1090
       long symbol)
1091
283
{
1092
283
  struct coff_comdat_info *comdat;
1093
283
  size_t len = strlen (symname) + 1;
1094
1095
283
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
283
  if (comdat == NULL)
1097
0
    return false;
1098
1099
283
  coff_section_data (abfd, section)->comdat = comdat;
1100
283
  comdat->symbol = symbol;
1101
283
  char *newname = (char *) (comdat + 1);
1102
283
  comdat->name = newname;
1103
283
  memcpy (newname, symname, len);
1104
283
  return true;
1105
283
}
pei-i386.c:insert_coff_comdat_info
Line
Count
Source
1091
4
{
1092
4
  struct coff_comdat_info *comdat;
1093
4
  size_t len = strlen (symname) + 1;
1094
1095
4
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
4
  if (comdat == NULL)
1097
0
    return false;
1098
1099
4
  coff_section_data (abfd, section)->comdat = comdat;
1100
4
  comdat->symbol = symbol;
1101
4
  char *newname = (char *) (comdat + 1);
1102
4
  comdat->name = newname;
1103
4
  memcpy (newname, symname, len);
1104
4
  return true;
1105
4
}
pe-x86_64.c:insert_coff_comdat_info
Line
Count
Source
1091
17
{
1092
17
  struct coff_comdat_info *comdat;
1093
17
  size_t len = strlen (symname) + 1;
1094
1095
17
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
17
  if (comdat == NULL)
1097
0
    return false;
1098
1099
17
  coff_section_data (abfd, section)->comdat = comdat;
1100
17
  comdat->symbol = symbol;
1101
17
  char *newname = (char *) (comdat + 1);
1102
17
  comdat->name = newname;
1103
17
  memcpy (newname, symname, len);
1104
17
  return true;
1105
17
}
pei-x86_64.c:insert_coff_comdat_info
Line
Count
Source
1091
15
{
1092
15
  struct coff_comdat_info *comdat;
1093
15
  size_t len = strlen (symname) + 1;
1094
1095
15
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
15
  if (comdat == NULL)
1097
0
    return false;
1098
1099
15
  coff_section_data (abfd, section)->comdat = comdat;
1100
15
  comdat->symbol = symbol;
1101
15
  char *newname = (char *) (comdat + 1);
1102
15
  comdat->name = newname;
1103
15
  memcpy (newname, symname, len);
1104
15
  return true;
1105
15
}
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
54
{
1092
54
  struct coff_comdat_info *comdat;
1093
54
  size_t len = strlen (symname) + 1;
1094
1095
54
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
54
  if (comdat == NULL)
1097
0
    return false;
1098
1099
54
  coff_section_data (abfd, section)->comdat = comdat;
1100
54
  comdat->symbol = symbol;
1101
54
  char *newname = (char *) (comdat + 1);
1102
54
  comdat->name = newname;
1103
54
  memcpy (newname, symname, len);
1104
54
  return true;
1105
54
}
pei-ia64.c:insert_coff_comdat_info
Line
Count
Source
1091
15
{
1092
15
  struct coff_comdat_info *comdat;
1093
15
  size_t len = strlen (symname) + 1;
1094
1095
15
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
15
  if (comdat == NULL)
1097
0
    return false;
1098
1099
15
  coff_section_data (abfd, section)->comdat = comdat;
1100
15
  comdat->symbol = symbol;
1101
15
  char *newname = (char *) (comdat + 1);
1102
15
  comdat->name = newname;
1103
15
  memcpy (newname, symname, len);
1104
15
  return true;
1105
15
}
pei-loongarch64.c:insert_coff_comdat_info
Line
Count
Source
1091
26
{
1092
26
  struct coff_comdat_info *comdat;
1093
26
  size_t len = strlen (symname) + 1;
1094
1095
26
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
26
  if (comdat == NULL)
1097
0
    return false;
1098
1099
26
  coff_section_data (abfd, section)->comdat = comdat;
1100
26
  comdat->symbol = symbol;
1101
26
  char *newname = (char *) (comdat + 1);
1102
26
  comdat->name = newname;
1103
26
  memcpy (newname, symname, len);
1104
26
  return true;
1105
26
}
pe-arm-wince.c:insert_coff_comdat_info
Line
Count
Source
1091
16
{
1092
16
  struct coff_comdat_info *comdat;
1093
16
  size_t len = strlen (symname) + 1;
1094
1095
16
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
16
  if (comdat == NULL)
1097
0
    return false;
1098
1099
16
  coff_section_data (abfd, section)->comdat = comdat;
1100
16
  comdat->symbol = symbol;
1101
16
  char *newname = (char *) (comdat + 1);
1102
16
  comdat->name = newname;
1103
16
  memcpy (newname, symname, len);
1104
16
  return true;
1105
16
}
pe-arm.c:insert_coff_comdat_info
Line
Count
Source
1091
16
{
1092
16
  struct coff_comdat_info *comdat;
1093
16
  size_t len = strlen (symname) + 1;
1094
1095
16
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
16
  if (comdat == NULL)
1097
0
    return false;
1098
1099
16
  coff_section_data (abfd, section)->comdat = comdat;
1100
16
  comdat->symbol = symbol;
1101
16
  char *newname = (char *) (comdat + 1);
1102
16
  comdat->name = newname;
1103
16
  memcpy (newname, symname, len);
1104
16
  return true;
1105
16
}
pe-i386.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-mcore.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-sh.c:insert_coff_comdat_info
Line
Count
Source
1091
26
{
1092
26
  struct coff_comdat_info *comdat;
1093
26
  size_t len = strlen (symname) + 1;
1094
1095
26
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
26
  if (comdat == NULL)
1097
0
    return false;
1098
1099
26
  coff_section_data (abfd, section)->comdat = comdat;
1100
26
  comdat->symbol = symbol;
1101
26
  char *newname = (char *) (comdat + 1);
1102
26
  comdat->name = newname;
1103
26
  memcpy (newname, symname, len);
1104
26
  return true;
1105
26
}
pei-arm-wince.c:insert_coff_comdat_info
Line
Count
Source
1091
23
{
1092
23
  struct coff_comdat_info *comdat;
1093
23
  size_t len = strlen (symname) + 1;
1094
1095
23
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
23
  if (comdat == NULL)
1097
0
    return false;
1098
1099
23
  coff_section_data (abfd, section)->comdat = comdat;
1100
23
  comdat->symbol = symbol;
1101
23
  char *newname = (char *) (comdat + 1);
1102
23
  comdat->name = newname;
1103
23
  memcpy (newname, symname, len);
1104
23
  return true;
1105
23
}
pei-arm.c:insert_coff_comdat_info
Line
Count
Source
1091
27
{
1092
27
  struct coff_comdat_info *comdat;
1093
27
  size_t len = strlen (symname) + 1;
1094
1095
27
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
27
  if (comdat == NULL)
1097
0
    return false;
1098
1099
27
  coff_section_data (abfd, section)->comdat = comdat;
1100
27
  comdat->symbol = symbol;
1101
27
  char *newname = (char *) (comdat + 1);
1102
27
  comdat->name = newname;
1103
27
  memcpy (newname, symname, len);
1104
27
  return true;
1105
27
}
pei-mcore.c:insert_coff_comdat_info
Line
Count
Source
1091
11
{
1092
11
  struct coff_comdat_info *comdat;
1093
11
  size_t len = strlen (symname) + 1;
1094
1095
11
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
11
  if (comdat == NULL)
1097
0
    return false;
1098
1099
11
  coff_section_data (abfd, section)->comdat = comdat;
1100
11
  comdat->symbol = symbol;
1101
11
  char *newname = (char *) (comdat + 1);
1102
11
  comdat->name = newname;
1103
11
  memcpy (newname, symname, len);
1104
11
  return true;
1105
11
}
pei-sh.c:insert_coff_comdat_info
Line
Count
Source
1091
11
{
1092
11
  struct coff_comdat_info *comdat;
1093
11
  size_t len = strlen (symname) + 1;
1094
1095
11
  comdat = bfd_alloc (abfd, sizeof (*comdat) + len);
1096
11
  if (comdat == NULL)
1097
0
    return false;
1098
1099
11
  coff_section_data (abfd, section)->comdat = comdat;
1100
11
  comdat->symbol = symbol;
1101
11
  char *newname = (char *) (comdat + 1);
1102
11
  comdat->name = newname;
1103
11
  memcpy (newname, symname, len);
1104
11
  return true;
1105
11
}
1106
1107
static bool
1108
handle_COMDAT (bfd *abfd, flagword *sec_flags, const char *name,
1109
         asection *section)
1110
10.5k
{
1111
10.5k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
3.74k
    {
1113
3.74k
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
3.74k
             comdat_delf);
1115
3.74k
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
3.74k
    }
1118
1119
10.5k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
7.79k
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
10.5k
  struct comdat_hash_entry *found
1124
10.5k
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
10.5k
  if (found != NULL)
1126
982
    {
1127
982
      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
982
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
982
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
257
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
257
    _bfd_error_handler
1147
257
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
257
       abfd, found->symname);
1149
257
    return false;
1150
257
  }
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
725
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
523
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
523
            " does not match section name '%s'"),
1160
523
          abfd, found->symname, name);
1161
1162
725
      if (found->comdat_symbol != -1)
1163
283
  {
1164
283
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
283
           found->comdat_symbol))
1166
0
      return false;
1167
283
  }
1168
725
      *sec_flags = *sec_flags | found->sec_flags;
1169
725
      return true;
1170
725
    }
1171
9.60k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
9.60k
  return true;
1173
10.5k
}
pei-i386.c:handle_COMDAT
Line
Count
Source
1110
420
{
1111
420
  if (pe_data (abfd)->comdat_hash == NULL)
1112
149
    {
1113
149
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
149
             comdat_delf);
1115
149
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
149
    }
1118
1119
420
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
293
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
420
  struct comdat_hash_entry *found
1124
420
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
420
  if (found != NULL)
1126
19
    {
1127
19
      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
19
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
19
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
2
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
2
    _bfd_error_handler
1147
2
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
2
       abfd, found->symname);
1149
2
    return false;
1150
2
  }
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
17
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
14
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
14
            " does not match section name '%s'"),
1160
14
          abfd, found->symname, name);
1161
1162
17
      if (found->comdat_symbol != -1)
1163
4
  {
1164
4
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
4
           found->comdat_symbol))
1166
0
      return false;
1167
4
  }
1168
17
      *sec_flags = *sec_flags | found->sec_flags;
1169
17
      return true;
1170
17
    }
1171
401
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
401
  return true;
1173
420
}
pe-x86_64.c:handle_COMDAT
Line
Count
Source
1110
1.07k
{
1111
1.07k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
444
    {
1113
444
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
444
             comdat_delf);
1115
444
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
444
    }
1118
1119
1.07k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
804
    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
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
12
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
12
    _bfd_error_handler
1147
12
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
12
       abfd, found->symname);
1149
12
    return false;
1150
12
  }
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
38
      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
38
      if (found->comdat_symbol != -1)
1163
17
  {
1164
17
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
17
           found->comdat_symbol))
1166
0
      return false;
1167
17
  }
1168
38
      *sec_flags = *sec_flags | found->sec_flags;
1169
38
      return true;
1170
38
    }
1171
1.02k
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
1.02k
  return true;
1173
1.07k
}
pei-x86_64.c:handle_COMDAT
Line
Count
Source
1110
719
{
1111
719
  if (pe_data (abfd)->comdat_hash == NULL)
1112
230
    {
1113
230
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
230
             comdat_delf);
1115
230
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
230
    }
1118
1119
719
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
490
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
719
  struct comdat_hash_entry *found
1124
719
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
719
  if (found != NULL)
1126
68
    {
1127
68
      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
68
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
68
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
24
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
24
    _bfd_error_handler
1147
24
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
24
       abfd, found->symname);
1149
24
    return false;
1150
24
  }
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
23
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
23
            " does not match section name '%s'"),
1160
23
          abfd, found->symname, name);
1161
1162
44
      if (found->comdat_symbol != -1)
1163
15
  {
1164
15
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
15
           found->comdat_symbol))
1166
0
      return false;
1167
15
  }
1168
44
      *sec_flags = *sec_flags | found->sec_flags;
1169
44
      return true;
1170
44
    }
1171
651
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
651
  return true;
1173
719
}
pe-aarch64.c:handle_COMDAT
Line
Count
Source
1110
637
{
1111
637
  if (pe_data (abfd)->comdat_hash == NULL)
1112
144
    {
1113
144
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
144
             comdat_delf);
1115
144
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
144
    }
1118
1119
637
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
540
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
637
  struct comdat_hash_entry *found
1124
637
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
637
  if (found != NULL)
1126
25
    {
1127
25
      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
25
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
25
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
11
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
11
    _bfd_error_handler
1147
11
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
11
       abfd, found->symname);
1149
11
    return false;
1150
11
  }
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
5
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
5
            " does not match section name '%s'"),
1160
5
          abfd, found->symname, name);
1161
1162
14
      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
14
      *sec_flags = *sec_flags | found->sec_flags;
1169
14
      return true;
1170
14
    }
1171
612
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
612
  return true;
1173
637
}
pei-aarch64.c:handle_COMDAT
Line
Count
Source
1110
1.07k
{
1111
1.07k
  if (pe_data (abfd)->comdat_hash == NULL)
1112
221
    {
1113
221
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
221
             comdat_delf);
1115
221
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
221
    }
1118
1119
1.07k
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
750
    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
172
    {
1127
172
      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
172
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
172
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
54
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
54
    _bfd_error_handler
1147
54
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
54
       abfd, found->symname);
1149
54
    return false;
1150
54
  }
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
118
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
111
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
111
            " does not match section name '%s'"),
1160
111
          abfd, found->symname, name);
1161
1162
118
      if (found->comdat_symbol != -1)
1163
54
  {
1164
54
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
54
           found->comdat_symbol))
1166
0
      return false;
1167
54
  }
1168
118
      *sec_flags = *sec_flags | found->sec_flags;
1169
118
      return true;
1170
118
    }
1171
899
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
899
  return true;
1173
1.07k
}
pei-ia64.c:handle_COMDAT
Line
Count
Source
1110
593
{
1111
593
  if (pe_data (abfd)->comdat_hash == NULL)
1112
215
    {
1113
215
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
215
             comdat_delf);
1115
215
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
215
    }
1118
1119
593
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
446
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
593
  struct comdat_hash_entry *found
1124
593
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
593
  if (found != NULL)
1126
67
    {
1127
67
      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
67
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
67
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
18
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
18
    _bfd_error_handler
1147
18
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
18
       abfd, found->symname);
1149
18
    return false;
1150
18
  }
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
49
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
42
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
42
            " does not match section name '%s'"),
1160
42
          abfd, found->symname, name);
1161
1162
49
      if (found->comdat_symbol != -1)
1163
15
  {
1164
15
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
15
           found->comdat_symbol))
1166
0
      return false;
1167
15
  }
1168
49
      *sec_flags = *sec_flags | found->sec_flags;
1169
49
      return true;
1170
49
    }
1171
526
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
526
  return true;
1173
593
}
pei-loongarch64.c:handle_COMDAT
Line
Count
Source
1110
713
{
1111
713
  if (pe_data (abfd)->comdat_hash == NULL)
1112
234
    {
1113
234
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
234
             comdat_delf);
1115
234
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
234
    }
1118
1119
713
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
383
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
713
  struct comdat_hash_entry *found
1124
713
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
713
  if (found != NULL)
1126
93
    {
1127
93
      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
93
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
93
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
19
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
19
    _bfd_error_handler
1147
19
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
19
       abfd, found->symname);
1149
19
    return false;
1150
19
  }
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
74
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
66
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
66
            " does not match section name '%s'"),
1160
66
          abfd, found->symname, name);
1161
1162
74
      if (found->comdat_symbol != -1)
1163
26
  {
1164
26
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
26
           found->comdat_symbol))
1166
0
      return false;
1167
26
  }
1168
74
      *sec_flags = *sec_flags | found->sec_flags;
1169
74
      return true;
1170
74
    }
1171
620
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
620
  return true;
1173
713
}
pe-arm-wince.c:handle_COMDAT
Line
Count
Source
1110
562
{
1111
562
  if (pe_data (abfd)->comdat_hash == NULL)
1112
263
    {
1113
263
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
263
             comdat_delf);
1115
263
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
263
    }
1118
1119
562
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
436
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
562
  struct comdat_hash_entry *found
1124
562
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
562
  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
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
42
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
22
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
22
            " does not match section name '%s'"),
1160
22
          abfd, found->symname, name);
1161
1162
42
      if (found->comdat_symbol != -1)
1163
16
  {
1164
16
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
16
           found->comdat_symbol))
1166
0
      return false;
1167
16
  }
1168
42
      *sec_flags = *sec_flags | found->sec_flags;
1169
42
      return true;
1170
42
    }
1171
504
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
504
  return true;
1173
562
}
pe-arm.c:handle_COMDAT
Line
Count
Source
1110
562
{
1111
562
  if (pe_data (abfd)->comdat_hash == NULL)
1112
263
    {
1113
263
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
263
             comdat_delf);
1115
263
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
263
    }
1118
1119
562
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
436
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
562
  struct comdat_hash_entry *found
1124
562
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
562
  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
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
42
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
22
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
22
            " does not match section name '%s'"),
1160
22
          abfd, found->symname, name);
1161
1162
42
      if (found->comdat_symbol != -1)
1163
16
  {
1164
16
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
16
           found->comdat_symbol))
1166
0
      return false;
1167
16
  }
1168
42
      *sec_flags = *sec_flags | found->sec_flags;
1169
42
      return true;
1170
42
    }
1171
504
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
504
  return true;
1173
562
}
pe-i386.c:handle_COMDAT
Line
Count
Source
1110
806
{
1111
806
  if (pe_data (abfd)->comdat_hash == NULL)
1112
435
    {
1113
435
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
435
             comdat_delf);
1115
435
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
435
    }
1118
1119
806
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
645
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
806
  struct comdat_hash_entry *found
1124
806
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
806
  if (found != NULL)
1126
29
    {
1127
29
      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
29
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
29
       && 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
23
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
15
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
15
            " does not match section name '%s'"),
1160
15
          abfd, found->symname, name);
1161
1162
23
      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
23
      *sec_flags = *sec_flags | found->sec_flags;
1169
23
      return true;
1170
23
    }
1171
777
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
777
  return true;
1173
806
}
pe-mcore.c:handle_COMDAT
Line
Count
Source
1110
379
{
1111
379
  if (pe_data (abfd)->comdat_hash == NULL)
1112
157
    {
1113
157
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
157
             comdat_delf);
1115
157
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
157
    }
1118
1119
379
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
328
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
379
  struct comdat_hash_entry *found
1124
379
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
379
  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
9
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
9
    _bfd_error_handler
1147
9
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
9
       abfd, found->symname);
1149
9
    return false;
1150
9
  }
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
27
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
14
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
14
            " does not match section name '%s'"),
1160
14
          abfd, found->symname, name);
1161
1162
27
      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
27
      *sec_flags = *sec_flags | found->sec_flags;
1169
27
      return true;
1170
27
    }
1171
343
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
343
  return true;
1173
379
}
pe-sh.c:handle_COMDAT
Line
Count
Source
1110
705
{
1111
705
  if (pe_data (abfd)->comdat_hash == NULL)
1112
286
    {
1113
286
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
286
             comdat_delf);
1115
286
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
286
    }
1118
1119
705
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
535
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
705
  struct comdat_hash_entry *found
1124
705
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
705
  if (found != NULL)
1126
75
    {
1127
75
      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
75
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
75
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
19
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
19
    _bfd_error_handler
1147
19
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
19
       abfd, found->symname);
1149
19
    return false;
1150
19
  }
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
56
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
49
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
49
            " does not match section name '%s'"),
1160
49
          abfd, found->symname, name);
1161
1162
56
      if (found->comdat_symbol != -1)
1163
26
  {
1164
26
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
26
           found->comdat_symbol))
1166
0
      return false;
1167
26
  }
1168
56
      *sec_flags = *sec_flags | found->sec_flags;
1169
56
      return true;
1170
56
    }
1171
630
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
630
  return true;
1173
705
}
pei-arm-wince.c:handle_COMDAT
Line
Count
Source
1110
524
{
1111
524
  if (pe_data (abfd)->comdat_hash == NULL)
1112
191
    {
1113
191
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
191
             comdat_delf);
1115
191
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
191
    }
1118
1119
524
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
445
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
524
  struct comdat_hash_entry *found
1124
524
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
524
  if (found != NULL)
1126
63
    {
1127
63
      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
63
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
63
       && 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
49
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
32
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
32
            " does not match section name '%s'"),
1160
32
          abfd, found->symname, name);
1161
1162
49
      if (found->comdat_symbol != -1)
1163
23
  {
1164
23
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
23
           found->comdat_symbol))
1166
0
      return false;
1167
23
  }
1168
49
      *sec_flags = *sec_flags | found->sec_flags;
1169
49
      return true;
1170
49
    }
1171
461
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
461
  return true;
1173
524
}
pei-arm.c:handle_COMDAT
Line
Count
Source
1110
767
{
1111
767
  if (pe_data (abfd)->comdat_hash == NULL)
1112
231
    {
1113
231
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
231
             comdat_delf);
1115
231
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
231
    }
1118
1119
767
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
614
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
767
  struct comdat_hash_entry *found
1124
767
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
767
  if (found != NULL)
1126
79
    {
1127
79
      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
79
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
79
       && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0))
1143
17
  {
1144
    /* Malformed input files can trigger this test.
1145
       cf PR 21781.  */
1146
17
    _bfd_error_handler
1147
17
      (_("%pB: error: unexpected symbol '%s' in COMDAT section"),
1148
17
       abfd, found->symname);
1149
17
    return false;
1150
17
  }
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
62
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
44
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
44
            " does not match section name '%s'"),
1160
44
          abfd, found->symname, name);
1161
1162
62
      if (found->comdat_symbol != -1)
1163
27
  {
1164
27
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
27
           found->comdat_symbol))
1166
0
      return false;
1167
27
  }
1168
62
      *sec_flags = *sec_flags | found->sec_flags;
1169
62
      return true;
1170
62
    }
1171
688
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
688
  return true;
1173
767
}
pei-mcore.c:handle_COMDAT
Line
Count
Source
1110
659
{
1111
659
  if (pe_data (abfd)->comdat_hash == NULL)
1112
148
    {
1113
148
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
148
             comdat_delf);
1115
148
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
148
    }
1118
1119
659
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
345
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
659
  struct comdat_hash_entry *found
1124
659
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
659
  if (found != NULL)
1126
54
    {
1127
54
      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
54
      if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT)
1142
54
       && 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
40
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
35
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
35
            " does not match section name '%s'"),
1160
35
          abfd, found->symname, name);
1161
1162
40
      if (found->comdat_symbol != -1)
1163
11
  {
1164
11
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
11
           found->comdat_symbol))
1166
0
      return false;
1167
11
  }
1168
40
      *sec_flags = *sec_flags | found->sec_flags;
1169
40
      return true;
1170
40
    }
1171
605
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
605
  return true;
1173
659
}
pei-sh.c:handle_COMDAT
Line
Count
Source
1110
399
{
1111
399
  if (pe_data (abfd)->comdat_hash == NULL)
1112
129
    {
1113
129
      pe_data (abfd)->comdat_hash = htab_create (10, comdat_hashf, comdat_eqf,
1114
129
             comdat_delf);
1115
129
      if (pe_data (abfd)->comdat_hash == NULL)
1116
0
  return false;
1117
129
    }
1118
1119
399
  if (htab_elements (pe_data (abfd)->comdat_hash) == 0)
1120
302
    if (! fill_comdat_hash (abfd))
1121
0
      return false;
1122
1123
399
  struct comdat_hash_entry *found
1124
399
    = find_flags (pe_data (abfd)->comdat_hash, section->target_index);
1125
399
  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
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
30
      if (isym.n_sclass == C_STAT && strcmp (name, found->symname) != 0)
1157
  /* xgettext:c-format */
1158
21
  _bfd_error_handler (_("%pB: warning: COMDAT symbol '%s'"
1159
21
            " does not match section name '%s'"),
1160
21
          abfd, found->symname, name);
1161
1162
30
      if (found->comdat_symbol != -1)
1163
11
  {
1164
11
    if (! insert_coff_comdat_info (abfd, section, found->comdat_name,
1165
11
           found->comdat_symbol))
1166
0
      return false;
1167
11
  }
1168
30
      *sec_flags = *sec_flags | found->sec_flags;
1169
30
      return true;
1170
30
    }
1171
363
  *sec_flags = *sec_flags | SEC_LINK_ONCE;
1172
363
  return true;
1173
399
}
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
74.9k
{
1192
74.9k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
74.9k
  unsigned long styp_flags = internal_s->s_flags;
1194
74.9k
  flagword sec_flags;
1195
74.9k
  bool result = true;
1196
74.9k
  bool is_dbg = false;
1197
1198
74.9k
  if (startswith (name, DOT_DEBUG)
1199
74.9k
      || startswith (name, DOT_ZDEBUG)
1200
74.9k
#ifdef COFF_LONG_SECTION_NAMES
1201
74.9k
      || startswith (name, GNU_LINKONCE_WI)
1202
74.9k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
74.9k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
74.9k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
74.9k
      || startswith (name, GNU_DEBUGLINK)
1207
74.9k
      || startswith (name, GNU_DEBUGALTLINK)
1208
74.9k
#endif
1209
74.9k
      || startswith (name, ".stab"))
1210
958
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
74.9k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
74.9k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
65.2k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
419k
  while (styp_flags)
1220
344k
    {
1221
344k
      unsigned long flag = styp_flags & - styp_flags;
1222
344k
      char * unhandled = NULL;
1223
1224
344k
      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
344k
      switch (flag)
1231
344k
  {
1232
2.15k
  case STYP_DSECT:
1233
2.15k
    unhandled = "STYP_DSECT";
1234
2.15k
    break;
1235
2.09k
  case STYP_GROUP:
1236
2.09k
    unhandled = "STYP_GROUP";
1237
2.09k
    break;
1238
2.10k
  case STYP_COPY:
1239
2.10k
    unhandled = "STYP_COPY";
1240
2.10k
    break;
1241
2.23k
  case STYP_OVER:
1242
2.23k
    unhandled = "STYP_OVER";
1243
2.23k
    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
9.72k
  case IMAGE_SCN_MEM_READ:
1250
9.72k
    sec_flags &= ~SEC_COFF_NOREAD;
1251
9.72k
    break;
1252
13.8k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
13.8k
    break;
1255
2.23k
  case IMAGE_SCN_LNK_OTHER:
1256
2.23k
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
2.23k
    break;
1258
2.18k
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
2.18k
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
2.18k
    break;
1261
17.1k
  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
17.1k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
17.1k
        " %s in section %s"),
1268
17.1k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
17.1k
    break;
1270
16.4k
  case IMAGE_SCN_MEM_EXECUTE:
1271
16.4k
    sec_flags |= SEC_CODE;
1272
16.4k
    break;
1273
15.9k
  case IMAGE_SCN_MEM_WRITE:
1274
15.9k
    sec_flags &= ~ SEC_READONLY;
1275
15.9k
    break;
1276
16.9k
  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
16.9k
       if (is_dbg
1283
16.9k
#ifdef _COMMENT
1284
16.9k
        || strcmp (name, _COMMENT) == 0
1285
16.9k
#endif
1286
16.9k
        )
1287
380
      {
1288
380
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
380
      }
1290
16.9k
    break;
1291
8.55k
  case IMAGE_SCN_MEM_SHARED:
1292
8.55k
    sec_flags |= SEC_COFF_SHARED;
1293
8.55k
    break;
1294
14.7k
  case IMAGE_SCN_LNK_REMOVE:
1295
14.7k
    if (!is_dbg)
1296
14.3k
      sec_flags |= SEC_EXCLUDE;
1297
14.7k
    break;
1298
13.1k
  case IMAGE_SCN_CNT_CODE:
1299
13.1k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
13.1k
    break;
1301
8.45k
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
8.45k
    if (is_dbg)
1303
381
      sec_flags |= SEC_DEBUGGING;
1304
8.07k
    else
1305
8.07k
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
8.45k
    break;
1307
13.8k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
13.8k
    sec_flags |= SEC_ALLOC;
1309
13.8k
    break;
1310
16.1k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
#ifdef COFF_PAGE_SIZE
1318
15.5k
    sec_flags |= SEC_DEBUGGING;
1319
#endif
1320
16.1k
    break;
1321
10.5k
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
10.5k
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
257
      result = false;
1325
10.5k
    break;
1326
141k
  default:
1327
    /* Silently ignore for now.  */
1328
141k
    break;
1329
344k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
344k
      if (unhandled != NULL)
1333
13.0k
  {
1334
13.0k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
13.0k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
13.0k
       abfd, name, unhandled, flag);
1338
13.0k
    result = false;
1339
13.0k
  }
1340
344k
    }
1341
1342
74.9k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
74.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
20.8k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
#endif
1357
1358
74.9k
  if (flags_ptr)
1359
74.9k
    * flags_ptr = sec_flags;
1360
1361
74.9k
  return result;
1362
74.9k
}
pei-i386.c:styp_to_sec_flags
Line
Count
Source
1191
6.29k
{
1192
6.29k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
6.29k
  unsigned long styp_flags = internal_s->s_flags;
1194
6.29k
  flagword sec_flags;
1195
6.29k
  bool result = true;
1196
6.29k
  bool is_dbg = false;
1197
1198
6.29k
  if (startswith (name, DOT_DEBUG)
1199
6.29k
      || startswith (name, DOT_ZDEBUG)
1200
6.29k
#ifdef COFF_LONG_SECTION_NAMES
1201
6.29k
      || startswith (name, GNU_LINKONCE_WI)
1202
6.29k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
6.29k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
6.29k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
6.29k
      || startswith (name, GNU_DEBUGLINK)
1207
6.29k
      || startswith (name, GNU_DEBUGALTLINK)
1208
6.29k
#endif
1209
6.29k
      || startswith (name, ".stab"))
1210
45
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
6.29k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
6.29k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
5.74k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
27.6k
  while (styp_flags)
1220
21.3k
    {
1221
21.3k
      unsigned long flag = styp_flags & - styp_flags;
1222
21.3k
      char * unhandled = NULL;
1223
1224
21.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
21.3k
      switch (flag)
1231
21.3k
  {
1232
50
  case STYP_DSECT:
1233
50
    unhandled = "STYP_DSECT";
1234
50
    break;
1235
58
  case STYP_GROUP:
1236
58
    unhandled = "STYP_GROUP";
1237
58
    break;
1238
60
  case STYP_COPY:
1239
60
    unhandled = "STYP_COPY";
1240
60
    break;
1241
61
  case STYP_OVER:
1242
61
    unhandled = "STYP_OVER";
1243
61
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
1.17k
  case STYP_NOLOAD:
1246
1.17k
    sec_flags |= SEC_NEVER_LOAD;
1247
1.17k
    break;
1248
0
#endif
1249
556
  case IMAGE_SCN_MEM_READ:
1250
556
    sec_flags &= ~SEC_COFF_NOREAD;
1251
556
    break;
1252
1.16k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.16k
    break;
1255
60
  case IMAGE_SCN_LNK_OTHER:
1256
60
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
60
    break;
1258
53
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
53
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
53
    break;
1261
1.21k
  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.21k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.21k
        " %s in section %s"),
1268
1.21k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.21k
    break;
1270
653
  case IMAGE_SCN_MEM_EXECUTE:
1271
653
    sec_flags |= SEC_CODE;
1272
653
    break;
1273
1.35k
  case IMAGE_SCN_MEM_WRITE:
1274
1.35k
    sec_flags &= ~ SEC_READONLY;
1275
1.35k
    break;
1276
1.27k
  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
1.27k
       if (is_dbg
1283
1.27k
#ifdef _COMMENT
1284
1.27k
        || strcmp (name, _COMMENT) == 0
1285
1.27k
#endif
1286
1.27k
        )
1287
37
      {
1288
37
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
37
      }
1290
1.27k
    break;
1291
257
  case IMAGE_SCN_MEM_SHARED:
1292
257
    sec_flags |= SEC_COFF_SHARED;
1293
257
    break;
1294
1.15k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.15k
    if (!is_dbg)
1296
1.13k
      sec_flags |= SEC_EXCLUDE;
1297
1.15k
    break;
1298
472
  case IMAGE_SCN_CNT_CODE:
1299
472
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
472
    break;
1301
457
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
457
    if (is_dbg)
1303
22
      sec_flags |= SEC_DEBUGGING;
1304
435
    else
1305
435
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
457
    break;
1307
1.10k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.10k
    sec_flags |= SEC_ALLOC;
1309
1.10k
    break;
1310
1.21k
  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.21k
#ifdef COFF_PAGE_SIZE
1318
1.21k
    sec_flags |= SEC_DEBUGGING;
1319
1.21k
#endif
1320
1.21k
    break;
1321
420
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
420
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
2
      result = false;
1325
420
    break;
1326
8.56k
  default:
1327
    /* Silently ignore for now.  */
1328
8.56k
    break;
1329
21.3k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
21.3k
      if (unhandled != NULL)
1333
342
  {
1334
342
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
342
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
342
       abfd, name, unhandled, flag);
1338
342
    result = false;
1339
342
  }
1340
21.3k
    }
1341
1342
6.29k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
6.29k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
6.29k
#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
6.29k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
6.29k
#endif
1357
1358
6.29k
  if (flags_ptr)
1359
6.29k
    * flags_ptr = sec_flags;
1360
1361
6.29k
  return result;
1362
6.29k
}
pe-x86_64.c:styp_to_sec_flags
Line
Count
Source
1191
5.62k
{
1192
5.62k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
5.62k
  unsigned long styp_flags = internal_s->s_flags;
1194
5.62k
  flagword sec_flags;
1195
5.62k
  bool result = true;
1196
5.62k
  bool is_dbg = false;
1197
1198
5.62k
  if (startswith (name, DOT_DEBUG)
1199
5.62k
      || startswith (name, DOT_ZDEBUG)
1200
5.62k
#ifdef COFF_LONG_SECTION_NAMES
1201
5.62k
      || startswith (name, GNU_LINKONCE_WI)
1202
5.62k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
5.62k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
5.62k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
5.62k
      || startswith (name, GNU_DEBUGLINK)
1207
5.62k
      || startswith (name, GNU_DEBUGALTLINK)
1208
5.62k
#endif
1209
5.62k
      || startswith (name, ".stab"))
1210
146
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
5.62k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
5.62k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
5.08k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
29.4k
  while (styp_flags)
1220
23.8k
    {
1221
23.8k
      unsigned long flag = styp_flags & - styp_flags;
1222
23.8k
      char * unhandled = NULL;
1223
1224
23.8k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
23.8k
      switch (flag)
1231
23.8k
  {
1232
192
  case STYP_DSECT:
1233
192
    unhandled = "STYP_DSECT";
1234
192
    break;
1235
186
  case STYP_GROUP:
1236
186
    unhandled = "STYP_GROUP";
1237
186
    break;
1238
191
  case STYP_COPY:
1239
191
    unhandled = "STYP_COPY";
1240
191
    break;
1241
221
  case STYP_OVER:
1242
221
    unhandled = "STYP_OVER";
1243
221
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
907
  case STYP_NOLOAD:
1246
907
    sec_flags |= SEC_NEVER_LOAD;
1247
907
    break;
1248
0
#endif
1249
541
  case IMAGE_SCN_MEM_READ:
1250
541
    sec_flags &= ~SEC_COFF_NOREAD;
1251
541
    break;
1252
905
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
905
    break;
1255
222
  case IMAGE_SCN_LNK_OTHER:
1256
222
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
222
    break;
1258
199
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
199
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
199
    break;
1261
1.20k
  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.20k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.20k
        " %s in section %s"),
1268
1.20k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.20k
    break;
1270
947
  case IMAGE_SCN_MEM_EXECUTE:
1271
947
    sec_flags |= SEC_CODE;
1272
947
    break;
1273
1.12k
  case IMAGE_SCN_MEM_WRITE:
1274
1.12k
    sec_flags &= ~ SEC_READONLY;
1275
1.12k
    break;
1276
875
  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
875
       if (is_dbg
1283
875
#ifdef _COMMENT
1284
875
        || strcmp (name, _COMMENT) == 0
1285
875
#endif
1286
875
        )
1287
41
      {
1288
41
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
41
      }
1290
875
    break;
1291
657
  case IMAGE_SCN_MEM_SHARED:
1292
657
    sec_flags |= SEC_COFF_SHARED;
1293
657
    break;
1294
1.01k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.01k
    if (!is_dbg)
1296
970
      sec_flags |= SEC_EXCLUDE;
1297
1.01k
    break;
1298
565
  case IMAGE_SCN_CNT_CODE:
1299
565
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
565
    break;
1301
458
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
458
    if (is_dbg)
1303
20
      sec_flags |= SEC_DEBUGGING;
1304
438
    else
1305
438
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
458
    break;
1307
821
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
821
    sec_flags |= SEC_ALLOC;
1309
821
    break;
1310
1.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
1.05k
#ifdef COFF_PAGE_SIZE
1318
1.05k
    sec_flags |= SEC_DEBUGGING;
1319
1.05k
#endif
1320
1.05k
    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
12
      result = false;
1325
1.07k
    break;
1326
10.5k
  default:
1327
    /* Silently ignore for now.  */
1328
10.5k
    break;
1329
23.8k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
23.8k
      if (unhandled != NULL)
1333
1.21k
  {
1334
1.21k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
1.21k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
1.21k
       abfd, name, unhandled, flag);
1338
1.21k
    result = false;
1339
1.21k
  }
1340
23.8k
    }
1341
1342
5.62k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
5.62k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
5.62k
#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
5.62k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
5.62k
#endif
1357
1358
5.62k
  if (flags_ptr)
1359
5.62k
    * flags_ptr = sec_flags;
1360
1361
5.62k
  return result;
1362
5.62k
}
pei-x86_64.c:styp_to_sec_flags
Line
Count
Source
1191
3.75k
{
1192
3.75k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
3.75k
  unsigned long styp_flags = internal_s->s_flags;
1194
3.75k
  flagword sec_flags;
1195
3.75k
  bool result = true;
1196
3.75k
  bool is_dbg = false;
1197
1198
3.75k
  if (startswith (name, DOT_DEBUG)
1199
3.75k
      || startswith (name, DOT_ZDEBUG)
1200
3.75k
#ifdef COFF_LONG_SECTION_NAMES
1201
3.75k
      || startswith (name, GNU_LINKONCE_WI)
1202
3.75k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
3.75k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
3.75k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
3.75k
      || startswith (name, GNU_DEBUGLINK)
1207
3.75k
      || startswith (name, GNU_DEBUGALTLINK)
1208
3.75k
#endif
1209
3.75k
      || startswith (name, ".stab"))
1210
81
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
3.75k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
3.75k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
2.96k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
21.6k
  while (styp_flags)
1220
17.9k
    {
1221
17.9k
      unsigned long flag = styp_flags & - styp_flags;
1222
17.9k
      char * unhandled = NULL;
1223
1224
17.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
17.9k
      switch (flag)
1231
17.9k
  {
1232
74
  case STYP_DSECT:
1233
74
    unhandled = "STYP_DSECT";
1234
74
    break;
1235
78
  case STYP_GROUP:
1236
78
    unhandled = "STYP_GROUP";
1237
78
    break;
1238
60
  case STYP_COPY:
1239
60
    unhandled = "STYP_COPY";
1240
60
    break;
1241
56
  case STYP_OVER:
1242
56
    unhandled = "STYP_OVER";
1243
56
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
530
  case STYP_NOLOAD:
1246
530
    sec_flags |= SEC_NEVER_LOAD;
1247
530
    break;
1248
0
#endif
1249
788
  case IMAGE_SCN_MEM_READ:
1250
788
    sec_flags &= ~SEC_COFF_NOREAD;
1251
788
    break;
1252
684
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
684
    break;
1255
71
  case IMAGE_SCN_LNK_OTHER:
1256
71
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
71
    break;
1258
65
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
65
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
65
    break;
1261
724
  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
724
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
724
        " %s in section %s"),
1268
724
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
724
    break;
1270
764
  case IMAGE_SCN_MEM_EXECUTE:
1271
764
    sec_flags |= SEC_CODE;
1272
764
    break;
1273
819
  case IMAGE_SCN_MEM_WRITE:
1274
819
    sec_flags &= ~ SEC_READONLY;
1275
819
    break;
1276
669
  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
669
       if (is_dbg
1283
669
#ifdef _COMMENT
1284
669
        || strcmp (name, _COMMENT) == 0
1285
669
#endif
1286
669
        )
1287
32
      {
1288
32
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
32
      }
1290
669
    break;
1291
338
  case IMAGE_SCN_MEM_SHARED:
1292
338
    sec_flags |= SEC_COFF_SHARED;
1293
338
    break;
1294
803
  case IMAGE_SCN_LNK_REMOVE:
1295
803
    if (!is_dbg)
1296
779
      sec_flags |= SEC_EXCLUDE;
1297
803
    break;
1298
594
  case IMAGE_SCN_CNT_CODE:
1299
594
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
594
    break;
1301
734
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
734
    if (is_dbg)
1303
36
      sec_flags |= SEC_DEBUGGING;
1304
698
    else
1305
698
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
734
    break;
1307
622
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
622
    sec_flags |= SEC_ALLOC;
1309
622
    break;
1310
574
  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
574
#ifdef COFF_PAGE_SIZE
1318
574
    sec_flags |= SEC_DEBUGGING;
1319
574
#endif
1320
574
    break;
1321
719
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
719
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
24
      result = false;
1325
719
    break;
1326
8.16k
  default:
1327
    /* Silently ignore for now.  */
1328
8.16k
    break;
1329
17.9k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
17.9k
      if (unhandled != NULL)
1333
404
  {
1334
404
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
404
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
404
       abfd, name, unhandled, flag);
1338
404
    result = false;
1339
404
  }
1340
17.9k
    }
1341
1342
3.75k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
3.75k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
3.75k
#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.75k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
3.75k
#endif
1357
1358
3.75k
  if (flags_ptr)
1359
3.75k
    * flags_ptr = sec_flags;
1360
1361
3.75k
  return result;
1362
3.75k
}
pe-aarch64.c:styp_to_sec_flags
Line
Count
Source
1191
4.33k
{
1192
4.33k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
4.33k
  unsigned long styp_flags = internal_s->s_flags;
1194
4.33k
  flagword sec_flags;
1195
4.33k
  bool result = true;
1196
4.33k
  bool is_dbg = false;
1197
1198
4.33k
  if (startswith (name, DOT_DEBUG)
1199
4.33k
      || startswith (name, DOT_ZDEBUG)
1200
4.33k
#ifdef COFF_LONG_SECTION_NAMES
1201
4.33k
      || startswith (name, GNU_LINKONCE_WI)
1202
4.33k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
4.33k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
4.33k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
4.33k
      || startswith (name, GNU_DEBUGLINK)
1207
4.33k
      || startswith (name, GNU_DEBUGALTLINK)
1208
4.33k
#endif
1209
4.33k
      || startswith (name, ".stab"))
1210
43
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
4.33k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
4.33k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
3.98k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
21.4k
  while (styp_flags)
1220
17.1k
    {
1221
17.1k
      unsigned long flag = styp_flags & - styp_flags;
1222
17.1k
      char * unhandled = NULL;
1223
1224
17.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
17.1k
      switch (flag)
1231
17.1k
  {
1232
78
  case STYP_DSECT:
1233
78
    unhandled = "STYP_DSECT";
1234
78
    break;
1235
87
  case STYP_GROUP:
1236
87
    unhandled = "STYP_GROUP";
1237
87
    break;
1238
101
  case STYP_COPY:
1239
101
    unhandled = "STYP_COPY";
1240
101
    break;
1241
80
  case STYP_OVER:
1242
80
    unhandled = "STYP_OVER";
1243
80
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
543
  case STYP_NOLOAD:
1246
543
    sec_flags |= SEC_NEVER_LOAD;
1247
543
    break;
1248
0
#endif
1249
347
  case IMAGE_SCN_MEM_READ:
1250
347
    sec_flags &= ~SEC_COFF_NOREAD;
1251
347
    break;
1252
680
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
680
    break;
1255
89
  case IMAGE_SCN_LNK_OTHER:
1256
89
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
89
    break;
1258
98
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
98
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
98
    break;
1261
969
  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
969
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
969
        " %s in section %s"),
1268
969
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
969
    break;
1270
676
  case IMAGE_SCN_MEM_EXECUTE:
1271
676
    sec_flags |= SEC_CODE;
1272
676
    break;
1273
924
  case IMAGE_SCN_MEM_WRITE:
1274
924
    sec_flags &= ~ SEC_READONLY;
1275
924
    break;
1276
979
  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
979
       if (is_dbg
1283
979
#ifdef _COMMENT
1284
979
        || strcmp (name, _COMMENT) == 0
1285
979
#endif
1286
979
        )
1287
24
      {
1288
24
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
24
      }
1290
979
    break;
1291
688
  case IMAGE_SCN_MEM_SHARED:
1292
688
    sec_flags |= SEC_COFF_SHARED;
1293
688
    break;
1294
688
  case IMAGE_SCN_LNK_REMOVE:
1295
688
    if (!is_dbg)
1296
664
      sec_flags |= SEC_EXCLUDE;
1297
688
    break;
1298
380
  case IMAGE_SCN_CNT_CODE:
1299
380
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
380
    break;
1301
296
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
296
    if (is_dbg)
1303
24
      sec_flags |= SEC_DEBUGGING;
1304
272
    else
1305
272
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
296
    break;
1307
697
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
697
    sec_flags |= SEC_ALLOC;
1309
697
    break;
1310
617
  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
617
#ifdef COFF_PAGE_SIZE
1318
617
    sec_flags |= SEC_DEBUGGING;
1319
617
#endif
1320
617
    break;
1321
637
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
637
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
11
      result = false;
1325
637
    break;
1326
7.50k
  default:
1327
    /* Silently ignore for now.  */
1328
7.50k
    break;
1329
17.1k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
17.1k
      if (unhandled != NULL)
1333
533
  {
1334
533
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
533
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
533
       abfd, name, unhandled, flag);
1338
533
    result = false;
1339
533
  }
1340
17.1k
    }
1341
1342
4.33k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
4.33k
      && (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.33k
  if (flags_ptr)
1359
4.33k
    * flags_ptr = sec_flags;
1360
1361
4.33k
  return result;
1362
4.33k
}
pei-aarch64.c:styp_to_sec_flags
Line
Count
Source
1191
7.84k
{
1192
7.84k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
7.84k
  unsigned long styp_flags = internal_s->s_flags;
1194
7.84k
  flagword sec_flags;
1195
7.84k
  bool result = true;
1196
7.84k
  bool is_dbg = false;
1197
1198
7.84k
  if (startswith (name, DOT_DEBUG)
1199
7.84k
      || startswith (name, DOT_ZDEBUG)
1200
7.84k
#ifdef COFF_LONG_SECTION_NAMES
1201
7.84k
      || startswith (name, GNU_LINKONCE_WI)
1202
7.84k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
7.84k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
7.84k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
7.84k
      || startswith (name, GNU_DEBUGLINK)
1207
7.84k
      || startswith (name, GNU_DEBUGALTLINK)
1208
7.84k
#endif
1209
7.84k
      || startswith (name, ".stab"))
1210
26
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
7.84k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
7.84k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
7.13k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
37.4k
  while (styp_flags)
1220
29.6k
    {
1221
29.6k
      unsigned long flag = styp_flags & - styp_flags;
1222
29.6k
      char * unhandled = NULL;
1223
1224
29.6k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
29.6k
      switch (flag)
1231
29.6k
  {
1232
103
  case STYP_DSECT:
1233
103
    unhandled = "STYP_DSECT";
1234
103
    break;
1235
90
  case STYP_GROUP:
1236
90
    unhandled = "STYP_GROUP";
1237
90
    break;
1238
124
  case STYP_COPY:
1239
124
    unhandled = "STYP_COPY";
1240
124
    break;
1241
104
  case STYP_OVER:
1242
104
    unhandled = "STYP_OVER";
1243
104
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.12k
  case STYP_NOLOAD:
1246
2.12k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.12k
    break;
1248
0
#endif
1249
709
  case IMAGE_SCN_MEM_READ:
1250
709
    sec_flags &= ~SEC_COFF_NOREAD;
1251
709
    break;
1252
1.19k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.19k
    break;
1255
100
  case IMAGE_SCN_LNK_OTHER:
1256
100
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
100
    break;
1258
87
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
87
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
87
    break;
1261
1.32k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
1.32k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.32k
        " %s in section %s"),
1268
1.32k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.32k
    break;
1270
1.21k
  case IMAGE_SCN_MEM_EXECUTE:
1271
1.21k
    sec_flags |= SEC_CODE;
1272
1.21k
    break;
1273
1.11k
  case IMAGE_SCN_MEM_WRITE:
1274
1.11k
    sec_flags &= ~ SEC_READONLY;
1275
1.11k
    break;
1276
2.25k
  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.25k
       if (is_dbg
1283
2.25k
#ifdef _COMMENT
1284
2.25k
        || strcmp (name, _COMMENT) == 0
1285
2.25k
#endif
1286
2.25k
        )
1287
16
      {
1288
16
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
16
      }
1290
2.25k
    break;
1291
675
  case IMAGE_SCN_MEM_SHARED:
1292
675
    sec_flags |= SEC_COFF_SHARED;
1293
675
    break;
1294
1.21k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.21k
    if (!is_dbg)
1296
1.20k
      sec_flags |= SEC_EXCLUDE;
1297
1.21k
    break;
1298
1.10k
  case IMAGE_SCN_CNT_CODE:
1299
1.10k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
1.10k
    break;
1301
666
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
666
    if (is_dbg)
1303
12
      sec_flags |= SEC_DEBUGGING;
1304
654
    else
1305
654
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
666
    break;
1307
1.08k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.08k
    sec_flags |= SEC_ALLOC;
1309
1.08k
    break;
1310
2.19k
  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.19k
#ifdef COFF_PAGE_SIZE
1318
2.19k
    sec_flags |= SEC_DEBUGGING;
1319
2.19k
#endif
1320
2.19k
    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
54
      result = false;
1325
1.07k
    break;
1326
11.0k
  default:
1327
    /* Silently ignore for now.  */
1328
11.0k
    break;
1329
29.6k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
29.6k
      if (unhandled != NULL)
1333
608
  {
1334
608
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
608
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
608
       abfd, name, unhandled, flag);
1338
608
    result = false;
1339
608
  }
1340
29.6k
    }
1341
1342
7.84k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
7.84k
      && (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
7.84k
  if (flags_ptr)
1359
7.84k
    * flags_ptr = sec_flags;
1360
1361
7.84k
  return result;
1362
7.84k
}
pei-ia64.c:styp_to_sec_flags
Line
Count
Source
1191
4.86k
{
1192
4.86k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
4.86k
  unsigned long styp_flags = internal_s->s_flags;
1194
4.86k
  flagword sec_flags;
1195
4.86k
  bool result = true;
1196
4.86k
  bool is_dbg = false;
1197
1198
4.86k
  if (startswith (name, DOT_DEBUG)
1199
4.86k
      || startswith (name, DOT_ZDEBUG)
1200
4.86k
#ifdef COFF_LONG_SECTION_NAMES
1201
4.86k
      || startswith (name, GNU_LINKONCE_WI)
1202
4.86k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
4.86k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
4.86k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
4.86k
      || startswith (name, GNU_DEBUGLINK)
1207
4.86k
      || startswith (name, GNU_DEBUGALTLINK)
1208
4.86k
#endif
1209
4.86k
      || startswith (name, ".stab"))
1210
41
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
4.86k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
4.86k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
4.30k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
20.8k
  while (styp_flags)
1220
16.0k
    {
1221
16.0k
      unsigned long flag = styp_flags & - styp_flags;
1222
16.0k
      char * unhandled = NULL;
1223
1224
16.0k
      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
16.0k
      switch (flag)
1231
16.0k
  {
1232
95
  case STYP_DSECT:
1233
95
    unhandled = "STYP_DSECT";
1234
95
    break;
1235
85
  case STYP_GROUP:
1236
85
    unhandled = "STYP_GROUP";
1237
85
    break;
1238
83
  case STYP_COPY:
1239
83
    unhandled = "STYP_COPY";
1240
83
    break;
1241
99
  case STYP_OVER:
1242
99
    unhandled = "STYP_OVER";
1243
99
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
677
  case STYP_NOLOAD:
1246
677
    sec_flags |= SEC_NEVER_LOAD;
1247
677
    break;
1248
0
#endif
1249
557
  case IMAGE_SCN_MEM_READ:
1250
557
    sec_flags &= ~SEC_COFF_NOREAD;
1251
557
    break;
1252
335
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
335
    break;
1255
107
  case IMAGE_SCN_LNK_OTHER:
1256
107
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
107
    break;
1258
106
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
106
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
106
    break;
1261
703
  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
703
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
703
        " %s in section %s"),
1268
703
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
703
    break;
1270
716
  case IMAGE_SCN_MEM_EXECUTE:
1271
716
    sec_flags |= SEC_CODE;
1272
716
    break;
1273
820
  case IMAGE_SCN_MEM_WRITE:
1274
820
    sec_flags &= ~ SEC_READONLY;
1275
820
    break;
1276
895
  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
895
       if (is_dbg
1283
895
#ifdef _COMMENT
1284
895
        || strcmp (name, _COMMENT) == 0
1285
895
#endif
1286
895
        )
1287
22
      {
1288
22
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
22
      }
1290
895
    break;
1291
639
  case IMAGE_SCN_MEM_SHARED:
1292
639
    sec_flags |= SEC_COFF_SHARED;
1293
639
    break;
1294
435
  case IMAGE_SCN_LNK_REMOVE:
1295
435
    if (!is_dbg)
1296
426
      sec_flags |= SEC_EXCLUDE;
1297
435
    break;
1298
365
  case IMAGE_SCN_CNT_CODE:
1299
365
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
365
    break;
1301
444
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
444
    if (is_dbg)
1303
17
      sec_flags |= SEC_DEBUGGING;
1304
427
    else
1305
427
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
444
    break;
1307
564
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
564
    sec_flags |= SEC_ALLOC;
1309
564
    break;
1310
771
  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
771
#ifdef COFF_PAGE_SIZE
1318
771
    sec_flags |= SEC_DEBUGGING;
1319
771
#endif
1320
771
    break;
1321
593
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
593
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
18
      result = false;
1325
593
    break;
1326
6.92k
  default:
1327
    /* Silently ignore for now.  */
1328
6.92k
    break;
1329
16.0k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
16.0k
      if (unhandled != NULL)
1333
575
  {
1334
575
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
575
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
575
       abfd, name, unhandled, flag);
1338
575
    result = false;
1339
575
  }
1340
16.0k
    }
1341
1342
4.86k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
4.86k
      && (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.86k
  if (flags_ptr)
1359
4.86k
    * flags_ptr = sec_flags;
1360
1361
4.86k
  return result;
1362
4.86k
}
pei-loongarch64.c:styp_to_sec_flags
Line
Count
Source
1191
6.09k
{
1192
6.09k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
6.09k
  unsigned long styp_flags = internal_s->s_flags;
1194
6.09k
  flagword sec_flags;
1195
6.09k
  bool result = true;
1196
6.09k
  bool is_dbg = false;
1197
1198
6.09k
  if (startswith (name, DOT_DEBUG)
1199
6.09k
      || startswith (name, DOT_ZDEBUG)
1200
6.09k
#ifdef COFF_LONG_SECTION_NAMES
1201
6.09k
      || startswith (name, GNU_LINKONCE_WI)
1202
6.09k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
6.09k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
6.09k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
6.09k
      || startswith (name, GNU_DEBUGLINK)
1207
6.09k
      || startswith (name, GNU_DEBUGALTLINK)
1208
6.09k
#endif
1209
6.09k
      || startswith (name, ".stab"))
1210
80
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
6.09k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
6.09k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
5.27k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
54.8k
  while (styp_flags)
1220
48.7k
    {
1221
48.7k
      unsigned long flag = styp_flags & - styp_flags;
1222
48.7k
      char * unhandled = NULL;
1223
1224
48.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
48.7k
      switch (flag)
1231
48.7k
  {
1232
151
  case STYP_DSECT:
1233
151
    unhandled = "STYP_DSECT";
1234
151
    break;
1235
137
  case STYP_GROUP:
1236
137
    unhandled = "STYP_GROUP";
1237
137
    break;
1238
112
  case STYP_COPY:
1239
112
    unhandled = "STYP_COPY";
1240
112
    break;
1241
137
  case STYP_OVER:
1242
137
    unhandled = "STYP_OVER";
1243
137
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
2.41k
  case STYP_NOLOAD:
1246
2.41k
    sec_flags |= SEC_NEVER_LOAD;
1247
2.41k
    break;
1248
0
#endif
1249
821
  case IMAGE_SCN_MEM_READ:
1250
821
    sec_flags &= ~SEC_COFF_NOREAD;
1251
821
    break;
1252
2.27k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
2.27k
    break;
1255
138
  case IMAGE_SCN_LNK_OTHER:
1256
138
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
138
    break;
1258
147
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
147
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
147
    break;
1261
2.59k
  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.59k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
2.59k
        " %s in section %s"),
1268
2.59k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
2.59k
    break;
1270
2.95k
  case IMAGE_SCN_MEM_EXECUTE:
1271
2.95k
    sec_flags |= SEC_CODE;
1272
2.95k
    break;
1273
2.67k
  case IMAGE_SCN_MEM_WRITE:
1274
2.67k
    sec_flags &= ~ SEC_READONLY;
1275
2.67k
    break;
1276
2.62k
  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.62k
       if (is_dbg
1283
2.62k
#ifdef _COMMENT
1284
2.62k
        || strcmp (name, _COMMENT) == 0
1285
2.62k
#endif
1286
2.62k
        )
1287
28
      {
1288
28
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
28
      }
1290
2.62k
    break;
1291
588
  case IMAGE_SCN_MEM_SHARED:
1292
588
    sec_flags |= SEC_COFF_SHARED;
1293
588
    break;
1294
2.27k
  case IMAGE_SCN_LNK_REMOVE:
1295
2.27k
    if (!is_dbg)
1296
2.21k
      sec_flags |= SEC_EXCLUDE;
1297
2.27k
    break;
1298
2.53k
  case IMAGE_SCN_CNT_CODE:
1299
2.53k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
2.53k
    break;
1301
732
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
732
    if (is_dbg)
1303
57
      sec_flags |= SEC_DEBUGGING;
1304
675
    else
1305
675
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
732
    break;
1307
2.51k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
2.51k
    sec_flags |= SEC_ALLOC;
1309
2.51k
    break;
1310
2.44k
  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.44k
#ifdef COFF_PAGE_SIZE
1318
2.44k
    sec_flags |= SEC_DEBUGGING;
1319
2.44k
#endif
1320
2.44k
    break;
1321
713
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
713
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
19
      result = false;
1325
713
    break;
1326
19.7k
  default:
1327
    /* Silently ignore for now.  */
1328
19.7k
    break;
1329
48.7k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
48.7k
      if (unhandled != NULL)
1333
822
  {
1334
822
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
822
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
822
       abfd, name, unhandled, flag);
1338
822
    result = false;
1339
822
  }
1340
48.7k
    }
1341
1342
6.09k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
6.09k
      && (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
6.09k
  if (flags_ptr)
1359
6.09k
    * flags_ptr = sec_flags;
1360
1361
6.09k
  return result;
1362
6.09k
}
pe-arm-wince.c:styp_to_sec_flags
Line
Count
Source
1191
3.20k
{
1192
3.20k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
3.20k
  unsigned long styp_flags = internal_s->s_flags;
1194
3.20k
  flagword sec_flags;
1195
3.20k
  bool result = true;
1196
3.20k
  bool is_dbg = false;
1197
1198
3.20k
  if (startswith (name, DOT_DEBUG)
1199
3.20k
      || startswith (name, DOT_ZDEBUG)
1200
3.20k
#ifdef COFF_LONG_SECTION_NAMES
1201
3.20k
      || startswith (name, GNU_LINKONCE_WI)
1202
3.20k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
3.20k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
3.20k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
3.20k
      || startswith (name, GNU_DEBUGLINK)
1207
3.20k
      || startswith (name, GNU_DEBUGALTLINK)
1208
3.20k
#endif
1209
3.20k
      || startswith (name, ".stab"))
1210
40
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
3.20k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
3.20k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
2.79k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
19.7k
  while (styp_flags)
1220
16.5k
    {
1221
16.5k
      unsigned long flag = styp_flags & - styp_flags;
1222
16.5k
      char * unhandled = NULL;
1223
1224
16.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
16.5k
      switch (flag)
1231
16.5k
  {
1232
186
  case STYP_DSECT:
1233
186
    unhandled = "STYP_DSECT";
1234
186
    break;
1235
183
  case STYP_GROUP:
1236
183
    unhandled = "STYP_GROUP";
1237
183
    break;
1238
181
  case STYP_COPY:
1239
181
    unhandled = "STYP_COPY";
1240
181
    break;
1241
193
  case STYP_OVER:
1242
193
    unhandled = "STYP_OVER";
1243
193
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
631
  case STYP_NOLOAD:
1246
631
    sec_flags |= SEC_NEVER_LOAD;
1247
631
    break;
1248
0
#endif
1249
409
  case IMAGE_SCN_MEM_READ:
1250
409
    sec_flags &= ~SEC_COFF_NOREAD;
1251
409
    break;
1252
634
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
634
    break;
1255
196
  case IMAGE_SCN_LNK_OTHER:
1256
196
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
196
    break;
1258
183
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
183
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
183
    break;
1261
766
  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
766
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
766
        " %s in section %s"),
1268
766
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
766
    break;
1270
953
  case IMAGE_SCN_MEM_EXECUTE:
1271
953
    sec_flags |= SEC_CODE;
1272
953
    break;
1273
654
  case IMAGE_SCN_MEM_WRITE:
1274
654
    sec_flags &= ~ SEC_READONLY;
1275
654
    break;
1276
776
  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
776
       if (is_dbg
1283
776
#ifdef _COMMENT
1284
776
        || strcmp (name, _COMMENT) == 0
1285
776
#endif
1286
776
        )
1287
12
      {
1288
12
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
12
      }
1290
776
    break;
1291
425
  case IMAGE_SCN_MEM_SHARED:
1292
425
    sec_flags |= SEC_COFF_SHARED;
1293
425
    break;
1294
682
  case IMAGE_SCN_LNK_REMOVE:
1295
682
    if (!is_dbg)
1296
669
      sec_flags |= SEC_EXCLUDE;
1297
682
    break;
1298
731
  case IMAGE_SCN_CNT_CODE:
1299
731
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
731
    break;
1301
349
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
349
    if (is_dbg)
1303
10
      sec_flags |= SEC_DEBUGGING;
1304
339
    else
1305
339
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
349
    break;
1307
528
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
528
    sec_flags |= SEC_ALLOC;
1309
528
    break;
1310
731
  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
731
#ifdef COFF_PAGE_SIZE
1318
731
    sec_flags |= SEC_DEBUGGING;
1319
731
#endif
1320
731
    break;
1321
562
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
562
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
16
      result = false;
1325
562
    break;
1326
6.55k
  default:
1327
    /* Silently ignore for now.  */
1328
6.55k
    break;
1329
16.5k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
16.5k
      if (unhandled != NULL)
1333
1.12k
  {
1334
1.12k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
1.12k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
1.12k
       abfd, name, unhandled, flag);
1338
1.12k
    result = false;
1339
1.12k
  }
1340
16.5k
    }
1341
1342
3.20k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
3.20k
      && (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
3.20k
  if (flags_ptr)
1359
3.20k
    * flags_ptr = sec_flags;
1360
1361
3.20k
  return result;
1362
3.20k
}
pe-arm.c:styp_to_sec_flags
Line
Count
Source
1191
3.20k
{
1192
3.20k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
3.20k
  unsigned long styp_flags = internal_s->s_flags;
1194
3.20k
  flagword sec_flags;
1195
3.20k
  bool result = true;
1196
3.20k
  bool is_dbg = false;
1197
1198
3.20k
  if (startswith (name, DOT_DEBUG)
1199
3.20k
      || startswith (name, DOT_ZDEBUG)
1200
3.20k
#ifdef COFF_LONG_SECTION_NAMES
1201
3.20k
      || startswith (name, GNU_LINKONCE_WI)
1202
3.20k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
3.20k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
3.20k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
3.20k
      || startswith (name, GNU_DEBUGLINK)
1207
3.20k
      || startswith (name, GNU_DEBUGALTLINK)
1208
3.20k
#endif
1209
3.20k
      || startswith (name, ".stab"))
1210
40
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
3.20k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
3.20k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
2.79k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
19.7k
  while (styp_flags)
1220
16.5k
    {
1221
16.5k
      unsigned long flag = styp_flags & - styp_flags;
1222
16.5k
      char * unhandled = NULL;
1223
1224
16.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
16.5k
      switch (flag)
1231
16.5k
  {
1232
186
  case STYP_DSECT:
1233
186
    unhandled = "STYP_DSECT";
1234
186
    break;
1235
183
  case STYP_GROUP:
1236
183
    unhandled = "STYP_GROUP";
1237
183
    break;
1238
181
  case STYP_COPY:
1239
181
    unhandled = "STYP_COPY";
1240
181
    break;
1241
193
  case STYP_OVER:
1242
193
    unhandled = "STYP_OVER";
1243
193
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
631
  case STYP_NOLOAD:
1246
631
    sec_flags |= SEC_NEVER_LOAD;
1247
631
    break;
1248
0
#endif
1249
409
  case IMAGE_SCN_MEM_READ:
1250
409
    sec_flags &= ~SEC_COFF_NOREAD;
1251
409
    break;
1252
634
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
634
    break;
1255
196
  case IMAGE_SCN_LNK_OTHER:
1256
196
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
196
    break;
1258
183
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
183
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
183
    break;
1261
766
  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
766
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
766
        " %s in section %s"),
1268
766
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
766
    break;
1270
953
  case IMAGE_SCN_MEM_EXECUTE:
1271
953
    sec_flags |= SEC_CODE;
1272
953
    break;
1273
654
  case IMAGE_SCN_MEM_WRITE:
1274
654
    sec_flags &= ~ SEC_READONLY;
1275
654
    break;
1276
776
  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
776
       if (is_dbg
1283
776
#ifdef _COMMENT
1284
776
        || strcmp (name, _COMMENT) == 0
1285
776
#endif
1286
776
        )
1287
12
      {
1288
12
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
12
      }
1290
776
    break;
1291
425
  case IMAGE_SCN_MEM_SHARED:
1292
425
    sec_flags |= SEC_COFF_SHARED;
1293
425
    break;
1294
682
  case IMAGE_SCN_LNK_REMOVE:
1295
682
    if (!is_dbg)
1296
669
      sec_flags |= SEC_EXCLUDE;
1297
682
    break;
1298
731
  case IMAGE_SCN_CNT_CODE:
1299
731
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
731
    break;
1301
349
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
349
    if (is_dbg)
1303
10
      sec_flags |= SEC_DEBUGGING;
1304
339
    else
1305
339
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
349
    break;
1307
528
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
528
    sec_flags |= SEC_ALLOC;
1309
528
    break;
1310
731
  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
731
#ifdef COFF_PAGE_SIZE
1318
731
    sec_flags |= SEC_DEBUGGING;
1319
731
#endif
1320
731
    break;
1321
562
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
562
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
16
      result = false;
1325
562
    break;
1326
6.55k
  default:
1327
    /* Silently ignore for now.  */
1328
6.55k
    break;
1329
16.5k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
16.5k
      if (unhandled != NULL)
1333
1.12k
  {
1334
1.12k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
1.12k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
1.12k
       abfd, name, unhandled, flag);
1338
1.12k
    result = false;
1339
1.12k
  }
1340
16.5k
    }
1341
1342
3.20k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
3.20k
      && (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
3.20k
  if (flags_ptr)
1359
3.20k
    * flags_ptr = sec_flags;
1360
1361
3.20k
  return result;
1362
3.20k
}
pe-i386.c:styp_to_sec_flags
Line
Count
Source
1191
5.13k
{
1192
5.13k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
5.13k
  unsigned long styp_flags = internal_s->s_flags;
1194
5.13k
  flagword sec_flags;
1195
5.13k
  bool result = true;
1196
5.13k
  bool is_dbg = false;
1197
1198
5.13k
  if (startswith (name, DOT_DEBUG)
1199
5.13k
      || startswith (name, DOT_ZDEBUG)
1200
5.13k
#ifdef COFF_LONG_SECTION_NAMES
1201
5.13k
      || startswith (name, GNU_LINKONCE_WI)
1202
5.13k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
5.13k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
5.13k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
5.13k
      || startswith (name, GNU_DEBUGLINK)
1207
5.13k
      || startswith (name, GNU_DEBUGALTLINK)
1208
5.13k
#endif
1209
5.13k
      || startswith (name, ".stab"))
1210
79
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
5.13k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
5.13k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
4.37k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
31.1k
  while (styp_flags)
1220
25.9k
    {
1221
25.9k
      unsigned long flag = styp_flags & - styp_flags;
1222
25.9k
      char * unhandled = NULL;
1223
1224
25.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
25.9k
      switch (flag)
1231
25.9k
  {
1232
384
  case STYP_DSECT:
1233
384
    unhandled = "STYP_DSECT";
1234
384
    break;
1235
382
  case STYP_GROUP:
1236
382
    unhandled = "STYP_GROUP";
1237
382
    break;
1238
331
  case STYP_COPY:
1239
331
    unhandled = "STYP_COPY";
1240
331
    break;
1241
392
  case STYP_OVER:
1242
392
    unhandled = "STYP_OVER";
1243
392
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
734
  case STYP_NOLOAD:
1246
734
    sec_flags |= SEC_NEVER_LOAD;
1247
734
    break;
1248
0
#endif
1249
763
  case IMAGE_SCN_MEM_READ:
1250
763
    sec_flags &= ~SEC_COFF_NOREAD;
1251
763
    break;
1252
863
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
863
    break;
1255
344
  case IMAGE_SCN_LNK_OTHER:
1256
344
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
344
    break;
1258
377
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
377
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
377
    break;
1261
1.18k
  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.18k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.18k
        " %s in section %s"),
1268
1.18k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.18k
    break;
1270
1.38k
  case IMAGE_SCN_MEM_EXECUTE:
1271
1.38k
    sec_flags |= SEC_CODE;
1272
1.38k
    break;
1273
1.12k
  case IMAGE_SCN_MEM_WRITE:
1274
1.12k
    sec_flags &= ~ SEC_READONLY;
1275
1.12k
    break;
1276
872
  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
872
       if (is_dbg
1283
872
#ifdef _COMMENT
1284
872
        || strcmp (name, _COMMENT) == 0
1285
872
#endif
1286
872
        )
1287
23
      {
1288
23
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
23
      }
1290
872
    break;
1291
822
  case IMAGE_SCN_MEM_SHARED:
1292
822
    sec_flags |= SEC_COFF_SHARED;
1293
822
    break;
1294
985
  case IMAGE_SCN_LNK_REMOVE:
1295
985
    if (!is_dbg)
1296
968
      sec_flags |= SEC_EXCLUDE;
1297
985
    break;
1298
1.17k
  case IMAGE_SCN_CNT_CODE:
1299
1.17k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
1.17k
    break;
1301
730
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
730
    if (is_dbg)
1303
29
      sec_flags |= SEC_DEBUGGING;
1304
701
    else
1305
701
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
730
    break;
1307
985
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
985
    sec_flags |= SEC_ALLOC;
1309
985
    break;
1310
819
  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
819
#ifdef COFF_PAGE_SIZE
1318
819
    sec_flags |= SEC_DEBUGGING;
1319
819
#endif
1320
819
    break;
1321
806
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
806
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
6
      result = false;
1325
806
    break;
1326
10.5k
  default:
1327
    /* Silently ignore for now.  */
1328
10.5k
    break;
1329
25.9k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
25.9k
      if (unhandled != NULL)
1333
2.21k
  {
1334
2.21k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
2.21k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
2.21k
       abfd, name, unhandled, flag);
1338
2.21k
    result = false;
1339
2.21k
  }
1340
25.9k
    }
1341
1342
5.13k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
5.13k
      && (startswith (name, ".sbss")
1344
0
    || startswith (name, ".sdata")))
1345
0
    sec_flags |= SEC_SMALL_DATA;
1346
1347
5.13k
#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
5.13k
  if (startswith (name, ".gnu.linkonce"))
1355
0
    sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
1356
5.13k
#endif
1357
1358
5.13k
  if (flags_ptr)
1359
5.13k
    * flags_ptr = sec_flags;
1360
1361
5.13k
  return result;
1362
5.13k
}
pe-mcore.c:styp_to_sec_flags
Line
Count
Source
1191
2.61k
{
1192
2.61k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
2.61k
  unsigned long styp_flags = internal_s->s_flags;
1194
2.61k
  flagword sec_flags;
1195
2.61k
  bool result = true;
1196
2.61k
  bool is_dbg = false;
1197
1198
2.61k
  if (startswith (name, DOT_DEBUG)
1199
2.61k
      || startswith (name, DOT_ZDEBUG)
1200
2.61k
#ifdef COFF_LONG_SECTION_NAMES
1201
2.61k
      || startswith (name, GNU_LINKONCE_WI)
1202
2.61k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
2.61k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
2.61k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
2.61k
      || startswith (name, GNU_DEBUGLINK)
1207
2.61k
      || startswith (name, GNU_DEBUGALTLINK)
1208
2.61k
#endif
1209
2.61k
      || startswith (name, ".stab"))
1210
44
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
2.61k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
2.61k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
1.92k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
18.7k
  while (styp_flags)
1220
16.1k
    {
1221
16.1k
      unsigned long flag = styp_flags & - styp_flags;
1222
16.1k
      char * unhandled = NULL;
1223
1224
16.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
16.1k
      switch (flag)
1231
16.1k
  {
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
103
  case STYP_COPY:
1239
103
    unhandled = "STYP_COPY";
1240
103
    break;
1241
110
  case STYP_OVER:
1242
110
    unhandled = "STYP_OVER";
1243
110
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
661
  case STYP_NOLOAD:
1246
661
    sec_flags |= SEC_NEVER_LOAD;
1247
661
    break;
1248
0
#endif
1249
684
  case IMAGE_SCN_MEM_READ:
1250
684
    sec_flags &= ~SEC_COFF_NOREAD;
1251
684
    break;
1252
596
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
596
    break;
1255
110
  case IMAGE_SCN_LNK_OTHER:
1256
110
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
110
    break;
1258
114
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
114
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
114
    break;
1261
721
  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
721
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
721
        " %s in section %s"),
1268
721
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
721
    break;
1270
750
  case IMAGE_SCN_MEM_EXECUTE:
1271
750
    sec_flags |= SEC_CODE;
1272
750
    break;
1273
553
  case IMAGE_SCN_MEM_WRITE:
1274
553
    sec_flags &= ~ SEC_READONLY;
1275
553
    break;
1276
739
  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
739
       if (is_dbg
1283
739
#ifdef _COMMENT
1284
739
        || strcmp (name, _COMMENT) == 0
1285
739
#endif
1286
739
        )
1287
9
      {
1288
9
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
9
      }
1290
739
    break;
1291
442
  case IMAGE_SCN_MEM_SHARED:
1292
442
    sec_flags |= SEC_COFF_SHARED;
1293
442
    break;
1294
601
  case IMAGE_SCN_LNK_REMOVE:
1295
601
    if (!is_dbg)
1296
590
      sec_flags |= SEC_EXCLUDE;
1297
601
    break;
1298
620
  case IMAGE_SCN_CNT_CODE:
1299
620
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
620
    break;
1301
609
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
609
    if (is_dbg)
1303
23
      sec_flags |= SEC_DEBUGGING;
1304
586
    else
1305
586
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
609
    break;
1307
508
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
508
    sec_flags |= SEC_ALLOC;
1309
508
    break;
1310
733
  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
733
#ifdef COFF_PAGE_SIZE
1318
733
    sec_flags |= SEC_DEBUGGING;
1319
733
#endif
1320
733
    break;
1321
379
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
379
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
9
      result = false;
1325
379
    break;
1326
6.87k
  default:
1327
    /* Silently ignore for now.  */
1328
6.87k
    break;
1329
16.1k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
16.1k
      if (unhandled != NULL)
1333
639
  {
1334
639
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
639
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
639
       abfd, name, unhandled, flag);
1338
639
    result = false;
1339
639
  }
1340
16.1k
    }
1341
1342
2.61k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
2.61k
      && (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.61k
  if (flags_ptr)
1359
2.61k
    * flags_ptr = sec_flags;
1360
1361
2.61k
  return result;
1362
2.61k
}
pe-sh.c:styp_to_sec_flags
Line
Count
Source
1191
3.23k
{
1192
3.23k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
3.23k
  unsigned long styp_flags = internal_s->s_flags;
1194
3.23k
  flagword sec_flags;
1195
3.23k
  bool result = true;
1196
3.23k
  bool is_dbg = false;
1197
1198
3.23k
  if (startswith (name, DOT_DEBUG)
1199
3.23k
      || startswith (name, DOT_ZDEBUG)
1200
3.23k
#ifdef COFF_LONG_SECTION_NAMES
1201
3.23k
      || startswith (name, GNU_LINKONCE_WI)
1202
3.23k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
3.23k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
3.23k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
3.23k
      || startswith (name, GNU_DEBUGLINK)
1207
3.23k
      || startswith (name, GNU_DEBUGALTLINK)
1208
3.23k
#endif
1209
3.23k
      || startswith (name, ".stab"))
1210
77
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
3.23k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
3.23k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
2.62k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
18.5k
  while (styp_flags)
1220
15.3k
    {
1221
15.3k
      unsigned long flag = styp_flags & - styp_flags;
1222
15.3k
      char * unhandled = NULL;
1223
1224
15.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
15.3k
      switch (flag)
1231
15.3k
  {
1232
183
  case STYP_DSECT:
1233
183
    unhandled = "STYP_DSECT";
1234
183
    break;
1235
177
  case STYP_GROUP:
1236
177
    unhandled = "STYP_GROUP";
1237
177
    break;
1238
196
  case STYP_COPY:
1239
196
    unhandled = "STYP_COPY";
1240
196
    break;
1241
180
  case STYP_OVER:
1242
180
    unhandled = "STYP_OVER";
1243
180
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
468
  case STYP_NOLOAD:
1246
468
    sec_flags |= SEC_NEVER_LOAD;
1247
468
    break;
1248
0
#endif
1249
605
  case IMAGE_SCN_MEM_READ:
1250
605
    sec_flags &= ~SEC_COFF_NOREAD;
1251
605
    break;
1252
531
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
531
    break;
1255
197
  case IMAGE_SCN_LNK_OTHER:
1256
197
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
197
    break;
1258
204
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
204
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
204
    break;
1261
661
  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
661
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
661
        " %s in section %s"),
1268
661
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
661
    break;
1270
612
  case IMAGE_SCN_MEM_EXECUTE:
1271
612
    sec_flags |= SEC_CODE;
1272
612
    break;
1273
593
  case IMAGE_SCN_MEM_WRITE:
1274
593
    sec_flags &= ~ SEC_READONLY;
1275
593
    break;
1276
536
  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
536
       if (is_dbg
1283
536
#ifdef _COMMENT
1284
536
        || strcmp (name, _COMMENT) == 0
1285
536
#endif
1286
536
        )
1287
20
      {
1288
20
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
20
      }
1290
536
    break;
1291
364
  case IMAGE_SCN_MEM_SHARED:
1292
364
    sec_flags |= SEC_COFF_SHARED;
1293
364
    break;
1294
615
  case IMAGE_SCN_LNK_REMOVE:
1295
615
    if (!is_dbg)
1296
594
      sec_flags |= SEC_EXCLUDE;
1297
615
    break;
1298
517
  case IMAGE_SCN_CNT_CODE:
1299
517
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
517
    break;
1301
555
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
555
    if (is_dbg)
1303
23
      sec_flags |= SEC_DEBUGGING;
1304
532
    else
1305
532
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
555
    break;
1307
535
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
535
    sec_flags |= SEC_ALLOC;
1309
535
    break;
1310
573
  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
573
    break;
1321
705
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
705
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
19
      result = false;
1325
705
    break;
1326
6.32k
  default:
1327
    /* Silently ignore for now.  */
1328
6.32k
    break;
1329
15.3k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
15.3k
      if (unhandled != NULL)
1333
1.13k
  {
1334
1.13k
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
1.13k
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
1.13k
       abfd, name, unhandled, flag);
1338
1.13k
    result = false;
1339
1.13k
  }
1340
15.3k
    }
1341
1342
3.23k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
3.23k
      && (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
3.23k
  if (flags_ptr)
1359
3.23k
    * flags_ptr = sec_flags;
1360
1361
3.23k
  return result;
1362
3.23k
}
pei-arm-wince.c:styp_to_sec_flags
Line
Count
Source
1191
5.00k
{
1192
5.00k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
5.00k
  unsigned long styp_flags = internal_s->s_flags;
1194
5.00k
  flagword sec_flags;
1195
5.00k
  bool result = true;
1196
5.00k
  bool is_dbg = false;
1197
1198
5.00k
  if (startswith (name, DOT_DEBUG)
1199
5.00k
      || startswith (name, DOT_ZDEBUG)
1200
5.00k
#ifdef COFF_LONG_SECTION_NAMES
1201
5.00k
      || startswith (name, GNU_LINKONCE_WI)
1202
5.00k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
5.00k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
5.00k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
5.00k
      || startswith (name, GNU_DEBUGLINK)
1207
5.00k
      || startswith (name, GNU_DEBUGALTLINK)
1208
5.00k
#endif
1209
5.00k
      || startswith (name, ".stab"))
1210
76
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
5.00k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
5.00k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
4.47k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
21.6k
  while (styp_flags)
1220
16.6k
    {
1221
16.6k
      unsigned long flag = styp_flags & - styp_flags;
1222
16.6k
      char * unhandled = NULL;
1223
1224
16.6k
      styp_flags &= ~ flag;
1225
1226
      /* We infer from the distinct read/write/execute bits the settings
1227
   of some of the bfd flags; the actual values, should we need them,
1228
   are also in pei_section_data (abfd, section)->pe_flags.  */
1229
1230
16.6k
      switch (flag)
1231
16.6k
  {
1232
94
  case STYP_DSECT:
1233
94
    unhandled = "STYP_DSECT";
1234
94
    break;
1235
92
  case STYP_GROUP:
1236
92
    unhandled = "STYP_GROUP";
1237
92
    break;
1238
95
  case STYP_COPY:
1239
95
    unhandled = "STYP_COPY";
1240
95
    break;
1241
113
  case STYP_OVER:
1242
113
    unhandled = "STYP_OVER";
1243
113
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
653
  case STYP_NOLOAD:
1246
653
    sec_flags |= SEC_NEVER_LOAD;
1247
653
    break;
1248
0
#endif
1249
534
  case IMAGE_SCN_MEM_READ:
1250
534
    sec_flags &= ~SEC_COFF_NOREAD;
1251
534
    break;
1252
659
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
659
    break;
1255
113
  case IMAGE_SCN_LNK_OTHER:
1256
113
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
113
    break;
1258
104
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
104
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
104
    break;
1261
1.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
1.02k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.02k
        " %s in section %s"),
1268
1.02k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.02k
    break;
1270
688
  case IMAGE_SCN_MEM_EXECUTE:
1271
688
    sec_flags |= SEC_CODE;
1272
688
    break;
1273
774
  case IMAGE_SCN_MEM_WRITE:
1274
774
    sec_flags &= ~ SEC_READONLY;
1275
774
    break;
1276
827
  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
827
       if (is_dbg
1283
827
#ifdef _COMMENT
1284
827
        || strcmp (name, _COMMENT) == 0
1285
827
#endif
1286
827
        )
1287
32
      {
1288
32
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
32
      }
1290
827
    break;
1291
544
  case IMAGE_SCN_MEM_SHARED:
1292
544
    sec_flags |= SEC_COFF_SHARED;
1293
544
    break;
1294
765
  case IMAGE_SCN_LNK_REMOVE:
1295
765
    if (!is_dbg)
1296
722
      sec_flags |= SEC_EXCLUDE;
1297
765
    break;
1298
612
  case IMAGE_SCN_CNT_CODE:
1299
612
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
612
    break;
1301
399
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
399
    if (is_dbg)
1303
37
      sec_flags |= SEC_DEBUGGING;
1304
362
    else
1305
362
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
399
    break;
1307
777
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
777
    sec_flags |= SEC_ALLOC;
1309
777
    break;
1310
814
  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
814
#ifdef COFF_PAGE_SIZE
1318
814
    sec_flags |= SEC_DEBUGGING;
1319
814
#endif
1320
814
    break;
1321
524
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
524
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
14
      result = false;
1325
524
    break;
1326
6.43k
  default:
1327
    /* Silently ignore for now.  */
1328
6.43k
    break;
1329
16.6k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
16.6k
      if (unhandled != NULL)
1333
611
  {
1334
611
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
611
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
611
       abfd, name, unhandled, flag);
1338
611
    result = false;
1339
611
  }
1340
16.6k
    }
1341
1342
5.00k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
5.00k
      && (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
5.00k
  if (flags_ptr)
1359
5.00k
    * flags_ptr = sec_flags;
1360
1361
5.00k
  return result;
1362
5.00k
}
pei-arm.c:styp_to_sec_flags
Line
Count
Source
1191
6.15k
{
1192
6.15k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
6.15k
  unsigned long styp_flags = internal_s->s_flags;
1194
6.15k
  flagword sec_flags;
1195
6.15k
  bool result = true;
1196
6.15k
  bool is_dbg = false;
1197
1198
6.15k
  if (startswith (name, DOT_DEBUG)
1199
6.15k
      || startswith (name, DOT_ZDEBUG)
1200
6.15k
#ifdef COFF_LONG_SECTION_NAMES
1201
6.15k
      || startswith (name, GNU_LINKONCE_WI)
1202
6.15k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
6.15k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
6.15k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
6.15k
      || startswith (name, GNU_DEBUGLINK)
1207
6.15k
      || startswith (name, GNU_DEBUGALTLINK)
1208
6.15k
#endif
1209
6.15k
      || startswith (name, ".stab"))
1210
78
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
6.15k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
6.15k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
5.53k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
30.3k
  while (styp_flags)
1220
24.2k
    {
1221
24.2k
      unsigned long flag = styp_flags & - styp_flags;
1222
24.2k
      char * unhandled = NULL;
1223
1224
24.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
24.2k
      switch (flag)
1231
24.2k
  {
1232
135
  case STYP_DSECT:
1233
135
    unhandled = "STYP_DSECT";
1234
135
    break;
1235
125
  case STYP_GROUP:
1236
125
    unhandled = "STYP_GROUP";
1237
125
    break;
1238
132
  case STYP_COPY:
1239
132
    unhandled = "STYP_COPY";
1240
132
    break;
1241
143
  case STYP_OVER:
1242
143
    unhandled = "STYP_OVER";
1243
143
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
923
  case STYP_NOLOAD:
1246
923
    sec_flags |= SEC_NEVER_LOAD;
1247
923
    break;
1248
0
#endif
1249
615
  case IMAGE_SCN_MEM_READ:
1250
615
    sec_flags &= ~SEC_COFF_NOREAD;
1251
615
    break;
1252
922
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
922
    break;
1255
142
  case IMAGE_SCN_LNK_OTHER:
1256
142
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
142
    break;
1258
122
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
122
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
122
    break;
1261
1.36k
  case IMAGE_SCN_MEM_NOT_PAGED:
1262
    /* Generate a warning message rather using the 'unhandled'
1263
       variable as this will allow some .sys files generate by
1264
       other toolchains to be processed.  See bugzilla issue 196.  */
1265
    /* xgettext:c-format */
1266
1.36k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.36k
        " %s in section %s"),
1268
1.36k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.36k
    break;
1270
1.33k
  case IMAGE_SCN_MEM_EXECUTE:
1271
1.33k
    sec_flags |= SEC_CODE;
1272
1.33k
    break;
1273
1.25k
  case IMAGE_SCN_MEM_WRITE:
1274
1.25k
    sec_flags &= ~ SEC_READONLY;
1275
1.25k
    break;
1276
1.13k
  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
1.13k
       if (is_dbg
1283
1.13k
#ifdef _COMMENT
1284
1.13k
        || strcmp (name, _COMMENT) == 0
1285
1.13k
#endif
1286
1.13k
        )
1287
34
      {
1288
34
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
34
      }
1290
1.13k
    break;
1291
1.11k
  case IMAGE_SCN_MEM_SHARED:
1292
1.11k
    sec_flags |= SEC_COFF_SHARED;
1293
1.11k
    break;
1294
1.01k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.01k
    if (!is_dbg)
1296
972
      sec_flags |= SEC_EXCLUDE;
1297
1.01k
    break;
1298
1.08k
  case IMAGE_SCN_CNT_CODE:
1299
1.08k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
1.08k
    break;
1301
435
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
435
    if (is_dbg)
1303
37
      sec_flags |= SEC_DEBUGGING;
1304
398
    else
1305
398
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
435
    break;
1307
1.07k
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
1.07k
    sec_flags |= SEC_ALLOC;
1309
1.07k
    break;
1310
1.10k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
1.10k
#ifdef COFF_PAGE_SIZE
1318
1.10k
    sec_flags |= SEC_DEBUGGING;
1319
1.10k
#endif
1320
1.10k
    break;
1321
767
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
767
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
17
      result = false;
1325
767
    break;
1326
9.25k
  default:
1327
    /* Silently ignore for now.  */
1328
9.25k
    break;
1329
24.2k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
24.2k
      if (unhandled != NULL)
1333
799
  {
1334
799
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
799
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
799
       abfd, name, unhandled, flag);
1338
799
    result = false;
1339
799
  }
1340
24.2k
    }
1341
1342
6.15k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
6.15k
      && (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
6.15k
  if (flags_ptr)
1359
6.15k
    * flags_ptr = sec_flags;
1360
1361
6.15k
  return result;
1362
6.15k
}
pei-mcore.c:styp_to_sec_flags
Line
Count
Source
1191
4.25k
{
1192
4.25k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
4.25k
  unsigned long styp_flags = internal_s->s_flags;
1194
4.25k
  flagword sec_flags;
1195
4.25k
  bool result = true;
1196
4.25k
  bool is_dbg = false;
1197
1198
4.25k
  if (startswith (name, DOT_DEBUG)
1199
4.25k
      || startswith (name, DOT_ZDEBUG)
1200
4.25k
#ifdef COFF_LONG_SECTION_NAMES
1201
4.25k
      || startswith (name, GNU_LINKONCE_WI)
1202
4.25k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
4.25k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
4.25k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
4.25k
      || startswith (name, GNU_DEBUGLINK)
1207
4.25k
      || startswith (name, GNU_DEBUGALTLINK)
1208
4.25k
#endif
1209
4.25k
      || startswith (name, ".stab"))
1210
28
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
4.25k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
4.25k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
3.33k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
27.5k
  while (styp_flags)
1220
23.2k
    {
1221
23.2k
      unsigned long flag = styp_flags & - styp_flags;
1222
23.2k
      char * unhandled = NULL;
1223
1224
23.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
23.2k
      switch (flag)
1231
23.2k
  {
1232
70
  case STYP_DSECT:
1233
70
    unhandled = "STYP_DSECT";
1234
70
    break;
1235
72
  case STYP_GROUP:
1236
72
    unhandled = "STYP_GROUP";
1237
72
    break;
1238
85
  case STYP_COPY:
1239
85
    unhandled = "STYP_COPY";
1240
85
    break;
1241
88
  case STYP_OVER:
1242
88
    unhandled = "STYP_OVER";
1243
88
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
1.30k
  case STYP_NOLOAD:
1246
1.30k
    sec_flags |= SEC_NEVER_LOAD;
1247
1.30k
    break;
1248
0
#endif
1249
916
  case IMAGE_SCN_MEM_READ:
1250
916
    sec_flags &= ~SEC_COFF_NOREAD;
1251
916
    break;
1252
1.04k
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
1.04k
    break;
1255
78
  case IMAGE_SCN_LNK_OTHER:
1256
78
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
78
    break;
1258
73
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
73
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
73
    break;
1261
1.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
1.12k
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
1.12k
        " %s in section %s"),
1268
1.12k
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
1.12k
    break;
1270
1.07k
  case IMAGE_SCN_MEM_EXECUTE:
1271
1.07k
    sec_flags |= SEC_CODE;
1272
1.07k
    break;
1273
590
  case IMAGE_SCN_MEM_WRITE:
1274
590
    sec_flags &= ~ SEC_READONLY;
1275
590
    break;
1276
1.26k
  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
1.26k
       if (is_dbg
1283
1.26k
#ifdef _COMMENT
1284
1.26k
        || strcmp (name, _COMMENT) == 0
1285
1.26k
#endif
1286
1.26k
        )
1287
13
      {
1288
13
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
13
      }
1290
1.26k
    break;
1291
248
  case IMAGE_SCN_MEM_SHARED:
1292
248
    sec_flags |= SEC_COFF_SHARED;
1293
248
    break;
1294
1.08k
  case IMAGE_SCN_LNK_REMOVE:
1295
1.08k
    if (!is_dbg)
1296
1.06k
      sec_flags |= SEC_EXCLUDE;
1297
1.08k
    break;
1298
1.06k
  case IMAGE_SCN_CNT_CODE:
1299
1.06k
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
1.06k
    break;
1301
824
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
824
    if (is_dbg)
1303
17
      sec_flags |= SEC_DEBUGGING;
1304
807
    else
1305
807
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
824
    break;
1307
612
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
612
    sec_flags |= SEC_ALLOC;
1309
612
    break;
1310
1.30k
  case IMAGE_SCN_LNK_INFO:
1311
    /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
1312
       defined.  coff_compute_section_file_positions uses
1313
       COFF_PAGE_SIZE to ensure that the low order bits of the
1314
       section VMA and the file offset match.  If we don't know
1315
       COFF_PAGE_SIZE, we can't ensure the correct correspondence,
1316
       and demand page loading of the file will fail.  */
1317
1.30k
#ifdef COFF_PAGE_SIZE
1318
1.30k
    sec_flags |= SEC_DEBUGGING;
1319
1.30k
#endif
1320
1.30k
    break;
1321
659
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
659
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
14
      result = false;
1325
659
    break;
1326
9.71k
  default:
1327
    /* Silently ignore for now.  */
1328
9.71k
    break;
1329
23.2k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
23.2k
      if (unhandled != NULL)
1333
466
  {
1334
466
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
466
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
466
       abfd, name, unhandled, flag);
1338
466
    result = false;
1339
466
  }
1340
23.2k
    }
1341
1342
4.25k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
4.25k
      && (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.25k
  if (flags_ptr)
1359
4.25k
    * flags_ptr = sec_flags;
1360
1361
4.25k
  return result;
1362
4.25k
}
pei-sh.c:styp_to_sec_flags
Line
Count
Source
1191
3.39k
{
1192
3.39k
  struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
1193
3.39k
  unsigned long styp_flags = internal_s->s_flags;
1194
3.39k
  flagword sec_flags;
1195
3.39k
  bool result = true;
1196
3.39k
  bool is_dbg = false;
1197
1198
3.39k
  if (startswith (name, DOT_DEBUG)
1199
3.39k
      || startswith (name, DOT_ZDEBUG)
1200
3.39k
#ifdef COFF_LONG_SECTION_NAMES
1201
3.39k
      || startswith (name, GNU_LINKONCE_WI)
1202
3.39k
      || startswith (name, GNU_LINKONCE_WT)
1203
      /* FIXME: These definitions ought to be in a header file.  */
1204
3.39k
#define GNU_DEBUGLINK   ".gnu_debuglink"
1205
3.39k
#define GNU_DEBUGALTLINK  ".gnu_debugaltlink"
1206
3.39k
      || startswith (name, GNU_DEBUGLINK)
1207
3.39k
      || startswith (name, GNU_DEBUGALTLINK)
1208
3.39k
#endif
1209
3.39k
      || startswith (name, ".stab"))
1210
34
    is_dbg = true;
1211
  /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified.  */
1212
3.39k
  sec_flags = SEC_READONLY;
1213
1214
  /* If section disallows read, then set the NOREAD flag. */
1215
3.39k
  if ((styp_flags & IMAGE_SCN_MEM_READ) == 0)
1216
2.91k
    sec_flags |= SEC_COFF_NOREAD;
1217
1218
  /* Process each flag bit in styp_flags in turn.  */
1219
18.6k
  while (styp_flags)
1220
15.2k
    {
1221
15.2k
      unsigned long flag = styp_flags & - styp_flags;
1222
15.2k
      char * unhandled = NULL;
1223
1224
15.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
15.2k
      switch (flag)
1231
15.2k
  {
1232
67
  case STYP_DSECT:
1233
67
    unhandled = "STYP_DSECT";
1234
67
    break;
1235
58
  case STYP_GROUP:
1236
58
    unhandled = "STYP_GROUP";
1237
58
    break;
1238
70
  case STYP_COPY:
1239
70
    unhandled = "STYP_COPY";
1240
70
    break;
1241
69
  case STYP_OVER:
1242
69
    unhandled = "STYP_OVER";
1243
69
    break;
1244
0
#ifdef SEC_NEVER_LOAD
1245
358
  case STYP_NOLOAD:
1246
358
    sec_flags |= SEC_NEVER_LOAD;
1247
358
    break;
1248
0
#endif
1249
474
  case IMAGE_SCN_MEM_READ:
1250
474
    sec_flags &= ~SEC_COFF_NOREAD;
1251
474
    break;
1252
728
  case IMAGE_SCN_TYPE_NO_PAD:
1253
    /* Skip.  */
1254
728
    break;
1255
74
  case IMAGE_SCN_LNK_OTHER:
1256
74
    unhandled = "IMAGE_SCN_LNK_OTHER";
1257
74
    break;
1258
69
  case IMAGE_SCN_MEM_NOT_CACHED:
1259
69
    unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
1260
69
    break;
1261
781
  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
781
    _bfd_error_handler (_("%pB: warning: ignoring section flag"
1267
781
        " %s in section %s"),
1268
781
            abfd, "IMAGE_SCN_MEM_NOT_PAGED", name);
1269
781
    break;
1270
823
  case IMAGE_SCN_MEM_EXECUTE:
1271
823
    sec_flags |= SEC_CODE;
1272
823
    break;
1273
974
  case IMAGE_SCN_MEM_WRITE:
1274
974
    sec_flags &= ~ SEC_READONLY;
1275
974
    break;
1276
432
  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
432
       if (is_dbg
1283
432
#ifdef _COMMENT
1284
432
        || strcmp (name, _COMMENT) == 0
1285
432
#endif
1286
432
        )
1287
25
      {
1288
25
        sec_flags |= SEC_DEBUGGING | SEC_READONLY;
1289
25
      }
1290
432
    break;
1291
330
  case IMAGE_SCN_MEM_SHARED:
1292
330
    sec_flags |= SEC_COFF_SHARED;
1293
330
    break;
1294
759
  case IMAGE_SCN_LNK_REMOVE:
1295
759
    if (!is_dbg)
1296
750
      sec_flags |= SEC_EXCLUDE;
1297
759
    break;
1298
591
  case IMAGE_SCN_CNT_CODE:
1299
591
    sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
1300
591
    break;
1301
415
  case IMAGE_SCN_CNT_INITIALIZED_DATA:
1302
415
    if (is_dbg)
1303
7
      sec_flags |= SEC_DEBUGGING;
1304
408
    else
1305
408
      sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
1306
415
    break;
1307
851
  case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
1308
851
    sec_flags |= SEC_ALLOC;
1309
851
    break;
1310
416
  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
416
#ifdef COFF_PAGE_SIZE
1318
416
    sec_flags |= SEC_DEBUGGING;
1319
416
#endif
1320
416
    break;
1321
399
  case IMAGE_SCN_LNK_COMDAT:
1322
    /* COMDAT gets very special treatment.  */
1323
399
    if (!handle_COMDAT (abfd, &sec_flags, name, section))
1324
6
      result = false;
1325
399
    break;
1326
6.48k
  default:
1327
    /* Silently ignore for now.  */
1328
6.48k
    break;
1329
15.2k
  }
1330
1331
      /* If the section flag was not handled, report it here.  */
1332
15.2k
      if (unhandled != NULL)
1333
407
  {
1334
407
    _bfd_error_handler
1335
      /* xgettext:c-format */
1336
407
      (_("%pB (%s): section flag %s (%#lx) ignored"),
1337
407
       abfd, name, unhandled, flag);
1338
407
    result = false;
1339
407
  }
1340
15.2k
    }
1341
1342
3.39k
  if ((bfd_applicable_section_flags (abfd) & SEC_SMALL_DATA) != 0
1343
3.39k
      && (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
3.39k
  if (flags_ptr)
1359
3.39k
    * flags_ptr = sec_flags;
1360
1361
3.39k
  return result;
1362
3.39k
}
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
402k
{
1687
402k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
402k
  if (BADMAG (*internal_f))
1690
390k
    return false;
1691
1692
12.5k
  return true;
1693
402k
}
pei-i386.c:coff_bad_format_hook
Line
Count
Source
1686
2.92k
{
1687
2.92k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
2.92k
  if (BADMAG (*internal_f))
1690
2.46k
    return false;
1691
1692
465
  return true;
1693
2.92k
}
pe-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
29.3k
{
1687
29.3k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
29.3k
  if (BADMAG (*internal_f))
1690
28.4k
    return false;
1691
1692
882
  return true;
1693
29.3k
}
pei-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
2.98k
{
1687
2.98k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
2.98k
  if (BADMAG (*internal_f))
1690
2.39k
    return false;
1691
1692
588
  return true;
1693
2.98k
}
coff-x86_64.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.3k
    return false;
1691
1692
623
  return true;
1693
15.9k
}
Unexecuted instantiation: coff64-rs6000.c:coff_bad_format_hook
pe-aarch64.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.6k
    return false;
1691
1692
263
  return true;
1693
15.9k
}
pei-aarch64.c:coff_bad_format_hook
Line
Count
Source
1686
2.85k
{
1687
2.85k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
2.85k
  if (BADMAG (*internal_f))
1690
2.39k
    return false;
1691
1692
459
  return true;
1693
2.85k
}
pei-ia64.c:coff_bad_format_hook
Line
Count
Source
1686
1.21k
{
1687
1.21k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
1.21k
  if (BADMAG (*internal_f))
1690
812
    return false;
1691
1692
407
  return true;
1693
1.21k
}
pei-loongarch64.c:coff_bad_format_hook
Line
Count
Source
1686
2.80k
{
1687
2.80k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
2.80k
  if (BADMAG (*internal_f))
1690
2.34k
    return false;
1691
1692
458
  return true;
1693
2.80k
}
cf-i386lynx.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.1k
    return false;
1691
1692
835
  return true;
1693
15.9k
}
coff-go32.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.2k
    return false;
1691
1692
651
  return true;
1693
15.9k
}
coff-i386.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.2k
    return false;
1691
1692
651
  return true;
1693
15.9k
}
coff-rs6000.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.5k
    return false;
1691
1692
423
  return true;
1693
15.9k
}
coff-sh.c:coff_bad_format_hook
Line
Count
Source
1686
31.8k
{
1687
31.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
31.8k
  if (BADMAG (*internal_f))
1690
31.3k
    return false;
1691
1692
499
  return true;
1693
31.8k
}
coff-stgo32.c:coff_bad_format_hook
Line
Count
Source
1686
201
{
1687
201
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
201
  if (BADMAG (*internal_f))
1690
1
    return false;
1691
1692
200
  return true;
1693
201
}
coff-tic30.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.7k
    return false;
1691
1692
183
  return true;
1693
15.9k
}
Unexecuted instantiation: coff-tic4x.c:coff_bad_format_hook
coff-tic54x.c:coff_bad_format_hook
Line
Count
Source
1686
31.0k
{
1687
31.0k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
31.0k
  if (BADMAG (*internal_f))
1690
31.0k
    return false;
1691
1692
18
  return true;
1693
31.0k
}
coff-z80.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.8k
    return false;
1691
1692
139
  return true;
1693
15.9k
}
coff-z8k.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.7k
    return false;
1691
1692
153
  return true;
1693
15.9k
}
pe-arm-wince.c:coff_bad_format_hook
Line
Count
Source
1686
31.8k
{
1687
31.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
31.8k
  if (BADMAG (*internal_f))
1690
31.4k
    return false;
1691
1692
450
  return true;
1693
31.8k
}
pe-arm.c:coff_bad_format_hook
Line
Count
Source
1686
31.8k
{
1687
31.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
31.8k
  if (BADMAG (*internal_f))
1690
31.4k
    return false;
1691
1692
450
  return true;
1693
31.8k
}
pe-i386.c:coff_bad_format_hook
Line
Count
Source
1686
29.1k
{
1687
29.1k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
29.1k
  if (BADMAG (*internal_f))
1690
28.2k
    return false;
1691
1692
898
  return true;
1693
29.1k
}
pe-mcore.c:coff_bad_format_hook
Line
Count
Source
1686
31.8k
{
1687
31.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
31.8k
  if (BADMAG (*internal_f))
1690
31.6k
    return false;
1691
1692
288
  return true;
1693
31.8k
}
pe-sh.c:coff_bad_format_hook
Line
Count
Source
1686
15.9k
{
1687
15.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
15.9k
  if (BADMAG (*internal_f))
1690
15.4k
    return false;
1691
1692
488
  return true;
1693
15.9k
}
pei-arm-wince.c:coff_bad_format_hook
Line
Count
Source
1686
3.53k
{
1687
3.53k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
3.53k
  if (BADMAG (*internal_f))
1690
2.85k
    return false;
1691
1692
682
  return true;
1693
3.53k
}
pei-arm.c:coff_bad_format_hook
Line
Count
Source
1686
3.53k
{
1687
3.53k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
3.53k
  if (BADMAG (*internal_f))
1690
2.85k
    return false;
1691
1692
682
  return true;
1693
3.53k
}
pei-mcore.c:coff_bad_format_hook
Line
Count
Source
1686
3.48k
{
1687
3.48k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
3.48k
  if (BADMAG (*internal_f))
1690
3.09k
    return false;
1691
1692
384
  return true;
1693
3.48k
}
pei-sh.c:coff_bad_format_hook
Line
Count
Source
1686
2.80k
{
1687
2.80k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1688
1689
2.80k
  if (BADMAG (*internal_f))
1690
2.46k
    return false;
1691
1692
334
  return true;
1693
2.80k
}
1694
1695
#ifdef TICOFF
1696
static bool
1697
ticoff0_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr)
1698
31.8k
{
1699
31.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1700
1701
31.8k
  if (COFF0_BADMAG (*internal_f))
1702
31.7k
    return false;
1703
1704
128
  return true;
1705
31.8k
}
Unexecuted instantiation: coff-tic4x.c:ticoff0_bad_format_hook
coff-tic54x.c:ticoff0_bad_format_hook
Line
Count
Source
1698
31.8k
{
1699
31.8k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1700
1701
31.8k
  if (COFF0_BADMAG (*internal_f))
1702
31.7k
    return false;
1703
1704
128
  return true;
1705
31.8k
}
1706
#endif
1707
1708
#ifdef TICOFF
1709
static bool
1710
ticoff1_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED, void * filehdr)
1711
31.0k
{
1712
31.0k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1713
1714
31.0k
  if (COFF1_BADMAG (*internal_f))
1715
31.0k
    return false;
1716
1717
2
  return true;
1718
31.0k
}
Unexecuted instantiation: coff-tic4x.c:ticoff1_bad_format_hook
coff-tic54x.c:ticoff1_bad_format_hook
Line
Count
Source
1711
31.0k
{
1712
31.0k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
1713
1714
31.0k
  if (COFF1_BADMAG (*internal_f))
1715
31.0k
    return false;
1716
1717
2
  return true;
1718
31.0k
}
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.00M
{
1730
2.00M
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
2.00M
  unsigned int i;
1732
1733
12.6M
  for (i = 0; i < table_size; ++i)
1734
10.6M
    {
1735
10.6M
      const char *secname = bfd_section_name (section);
1736
1737
10.6M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
10.6M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
10.6M
    : strncmp (alignment_table[i].name, secname,
1740
6.22M
         alignment_table[i].comparison_length) == 0)
1741
11.7k
  break;
1742
10.6M
    }
1743
2.00M
  if (i >= table_size)
1744
1.98M
    return;
1745
1746
11.7k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
11.7k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
4.73k
    return;
1749
1750
7.01k
  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
7.01k
      )
1755
0
    return;
1756
1757
7.01k
  section->alignment_power = alignment_table[i].alignment_power;
1758
7.01k
}
pei-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
6.35k
{
1730
6.35k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
6.35k
  unsigned int i;
1732
1733
56.8k
  for (i = 0; i < table_size; ++i)
1734
50.5k
    {
1735
50.5k
      const char *secname = bfd_section_name (section);
1736
1737
50.5k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
50.5k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
50.5k
    : strncmp (alignment_table[i].name, secname,
1740
31.6k
         alignment_table[i].comparison_length) == 0)
1741
72
  break;
1742
50.5k
    }
1743
6.35k
  if (i >= table_size)
1744
6.28k
    return;
1745
1746
72
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
72
      && default_alignment < alignment_table[i].default_alignment_min)
1748
29
    return;
1749
1750
43
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
43
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
43
      && default_alignment > alignment_table[i].default_alignment_max
1753
43
#endif
1754
43
      )
1755
0
    return;
1756
1757
43
  section->alignment_power = alignment_table[i].alignment_power;
1758
43
}
pe-x86_64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
5.65k
{
1730
5.65k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
5.65k
  unsigned int i;
1732
1733
78.0k
  for (i = 0; i < table_size; ++i)
1734
72.5k
    {
1735
72.5k
      const char *secname = bfd_section_name (section);
1736
1737
72.5k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
72.5k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
72.5k
    : strncmp (alignment_table[i].name, secname,
1740
50.3k
         alignment_table[i].comparison_length) == 0)
1741
182
  break;
1742
72.5k
    }
1743
5.65k
  if (i >= table_size)
1744
5.47k
    return;
1745
1746
182
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
182
      && default_alignment < alignment_table[i].default_alignment_min)
1748
52
    return;
1749
1750
130
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
130
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
130
      && default_alignment > alignment_table[i].default_alignment_max
1753
130
#endif
1754
130
      )
1755
0
    return;
1756
1757
130
  section->alignment_power = alignment_table[i].alignment_power;
1758
130
}
pei-x86_64.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
48.6k
  for (i = 0; i < table_size; ++i)
1734
45.0k
    {
1735
45.0k
      const char *secname = bfd_section_name (section);
1736
1737
45.0k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
45.0k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
45.0k
    : strncmp (alignment_table[i].name, secname,
1740
30.0k
         alignment_table[i].comparison_length) == 0)
1741
145
  break;
1742
45.0k
    }
1743
3.82k
  if (i >= table_size)
1744
3.67k
    return;
1745
1746
145
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
145
      && default_alignment < alignment_table[i].default_alignment_min)
1748
27
    return;
1749
1750
118
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
118
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
118
      && default_alignment > alignment_table[i].default_alignment_max
1753
118
#endif
1754
118
      )
1755
0
    return;
1756
1757
118
  section->alignment_power = alignment_table[i].alignment_power;
1758
118
}
coff-x86_64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
163k
{
1730
163k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
163k
  unsigned int i;
1732
1733
817k
  for (i = 0; i < table_size; ++i)
1734
653k
    {
1735
653k
      const char *secname = bfd_section_name (section);
1736
1737
653k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
653k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
653k
    : strncmp (alignment_table[i].name, secname,
1740
327k
         alignment_table[i].comparison_length) == 0)
1741
576
  break;
1742
653k
    }
1743
163k
  if (i >= table_size)
1744
163k
    return;
1745
1746
576
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
576
      && default_alignment < alignment_table[i].default_alignment_min)
1748
403
    return;
1749
1750
173
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
173
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
173
      && default_alignment > alignment_table[i].default_alignment_max
1753
173
#endif
1754
173
      )
1755
0
    return;
1756
1757
173
  section->alignment_power = alignment_table[i].alignment_power;
1758
173
}
coff64-rs6000.c:coff_set_custom_section_alignment
Line
Count
Source
1729
84.1k
{
1730
84.1k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
84.1k
  unsigned int i;
1732
1733
419k
  for (i = 0; i < table_size; ++i)
1734
335k
    {
1735
335k
      const char *secname = bfd_section_name (section);
1736
1737
335k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
335k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
335k
    : strncmp (alignment_table[i].name, secname,
1740
168k
         alignment_table[i].comparison_length) == 0)
1741
506
  break;
1742
335k
    }
1743
84.1k
  if (i >= table_size)
1744
83.6k
    return;
1745
1746
506
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
506
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
506
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
506
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
506
      && default_alignment > alignment_table[i].default_alignment_max
1753
506
#endif
1754
506
      )
1755
0
    return;
1756
1757
506
  section->alignment_power = alignment_table[i].alignment_power;
1758
506
}
pe-aarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
4.34k
{
1730
4.34k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
4.34k
  unsigned int i;
1732
1733
56.2k
  for (i = 0; i < table_size; ++i)
1734
51.9k
    {
1735
51.9k
      const char *secname = bfd_section_name (section);
1736
1737
51.9k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
51.9k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
51.9k
    : strncmp (alignment_table[i].name, secname,
1740
21.6k
         alignment_table[i].comparison_length) == 0)
1741
45
  break;
1742
51.9k
    }
1743
4.34k
  if (i >= table_size)
1744
4.29k
    return;
1745
1746
45
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
45
      && default_alignment < alignment_table[i].default_alignment_min)
1748
18
    return;
1749
1750
27
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
27
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
27
      && default_alignment > alignment_table[i].default_alignment_max
1753
27
#endif
1754
27
      )
1755
0
    return;
1756
1757
27
  section->alignment_power = alignment_table[i].alignment_power;
1758
27
}
pei-aarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
8.07k
{
1730
8.07k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
8.07k
  unsigned int i;
1732
1733
104k
  for (i = 0; i < table_size; ++i)
1734
96.3k
    {
1735
96.3k
      const char *secname = bfd_section_name (section);
1736
1737
96.3k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
96.3k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
96.3k
    : strncmp (alignment_table[i].name, secname,
1740
40.0k
         alignment_table[i].comparison_length) == 0)
1741
84
  break;
1742
96.3k
    }
1743
8.07k
  if (i >= table_size)
1744
7.99k
    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
11
    return;
1749
1750
73
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
73
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
73
      && default_alignment > alignment_table[i].default_alignment_max
1753
73
#endif
1754
73
      )
1755
0
    return;
1756
1757
73
  section->alignment_power = alignment_table[i].alignment_power;
1758
73
}
pei-ia64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
4.91k
{
1730
4.91k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
4.91k
  unsigned int i;
1732
1733
24.4k
  for (i = 0; i < table_size; ++i)
1734
19.5k
    {
1735
19.5k
      const char *secname = bfd_section_name (section);
1736
1737
19.5k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
19.5k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
19.5k
    : strncmp (alignment_table[i].name, secname,
1740
9.82k
         alignment_table[i].comparison_length) == 0)
1741
40
  break;
1742
19.5k
    }
1743
4.91k
  if (i >= table_size)
1744
4.87k
    return;
1745
1746
40
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
40
      && default_alignment < alignment_table[i].default_alignment_min)
1748
31
    return;
1749
1750
9
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
9
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
9
      && default_alignment > alignment_table[i].default_alignment_max
1753
9
#endif
1754
9
      )
1755
0
    return;
1756
1757
9
  section->alignment_power = alignment_table[i].alignment_power;
1758
9
}
pei-loongarch64.c:coff_set_custom_section_alignment
Line
Count
Source
1729
6.28k
{
1730
6.28k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
6.28k
  unsigned int i;
1732
1733
80.5k
  for (i = 0; i < table_size; ++i)
1734
74.4k
    {
1735
74.4k
      const char *secname = bfd_section_name (section);
1736
1737
74.4k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
74.4k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
74.4k
    : strncmp (alignment_table[i].name, secname,
1740
30.8k
         alignment_table[i].comparison_length) == 0)
1741
154
  break;
1742
74.4k
    }
1743
6.28k
  if (i >= table_size)
1744
6.12k
    return;
1745
1746
154
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
154
      && default_alignment < alignment_table[i].default_alignment_min)
1748
23
    return;
1749
1750
131
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
131
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
131
      && default_alignment > alignment_table[i].default_alignment_max
1753
131
#endif
1754
131
      )
1755
0
    return;
1756
1757
131
  section->alignment_power = alignment_table[i].alignment_power;
1758
131
}
cf-i386lynx.c:coff_set_custom_section_alignment
Line
Count
Source
1729
281k
{
1730
281k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
281k
  unsigned int i;
1732
1733
1.40M
  for (i = 0; i < table_size; ++i)
1734
1.12M
    {
1735
1.12M
      const char *secname = bfd_section_name (section);
1736
1737
1.12M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
1.12M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
1.12M
    : strncmp (alignment_table[i].name, secname,
1740
562k
         alignment_table[i].comparison_length) == 0)
1741
1.52k
  break;
1742
1.12M
    }
1743
281k
  if (i >= table_size)
1744
280k
    return;
1745
1746
1.52k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.52k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
947
    return;
1749
1750
575
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
575
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
575
      && default_alignment > alignment_table[i].default_alignment_max
1753
575
#endif
1754
575
      )
1755
0
    return;
1756
1757
575
  section->alignment_power = alignment_table[i].alignment_power;
1758
575
}
coff-go32.c:coff_set_custom_section_alignment
Line
Count
Source
1729
166k
{
1730
166k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
166k
  unsigned int i;
1732
1733
2.65M
  for (i = 0; i < table_size; ++i)
1734
2.48M
    {
1735
2.48M
      const char *secname = bfd_section_name (section);
1736
1737
2.48M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
2.48M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
2.48M
    : strncmp (alignment_table[i].name, secname,
1740
2.15M
         alignment_table[i].comparison_length) == 0)
1741
1.60k
  break;
1742
2.48M
    }
1743
166k
  if (i >= table_size)
1744
164k
    return;
1745
1746
1.60k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.60k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
552
    return;
1749
1750
1.05k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.05k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.05k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.05k
#endif
1754
1.05k
      )
1755
0
    return;
1756
1757
1.05k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.05k
}
coff-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
190k
{
1730
190k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
190k
  unsigned int i;
1732
1733
950k
  for (i = 0; i < table_size; ++i)
1734
760k
    {
1735
760k
      const char *secname = bfd_section_name (section);
1736
1737
760k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
760k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
760k
    : strncmp (alignment_table[i].name, secname,
1740
380k
         alignment_table[i].comparison_length) == 0)
1741
922
  break;
1742
760k
    }
1743
190k
  if (i >= table_size)
1744
189k
    return;
1745
1746
922
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
922
      && default_alignment < alignment_table[i].default_alignment_min)
1748
602
    return;
1749
1750
320
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
320
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
320
      && default_alignment > alignment_table[i].default_alignment_max
1753
320
#endif
1754
320
      )
1755
0
    return;
1756
1757
320
  section->alignment_power = alignment_table[i].alignment_power;
1758
320
}
coff-rs6000.c:coff_set_custom_section_alignment
Line
Count
Source
1729
490k
{
1730
490k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
490k
  unsigned int i;
1732
1733
2.45M
  for (i = 0; i < table_size; ++i)
1734
1.96M
    {
1735
1.96M
      const char *secname = bfd_section_name (section);
1736
1737
1.96M
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
1.96M
    ? strcmp (alignment_table[i].name, secname) == 0
1739
1.96M
    : strncmp (alignment_table[i].name, secname,
1740
981k
         alignment_table[i].comparison_length) == 0)
1741
1.70k
  break;
1742
1.96M
    }
1743
490k
  if (i >= table_size)
1744
489k
    return;
1745
1746
1.70k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.70k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
1.70k
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
1.70k
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
1.70k
      && default_alignment > alignment_table[i].default_alignment_max
1753
1.70k
#endif
1754
1.70k
      )
1755
0
    return;
1756
1757
1.70k
  section->alignment_power = alignment_table[i].alignment_power;
1758
1.70k
}
coff-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
139k
{
1730
139k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
139k
  unsigned int i;
1732
1733
695k
  for (i = 0; i < table_size; ++i)
1734
557k
    {
1735
557k
      const char *secname = bfd_section_name (section);
1736
1737
557k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
557k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
557k
    : strncmp (alignment_table[i].name, secname,
1740
278k
         alignment_table[i].comparison_length) == 0)
1741
765
  break;
1742
557k
    }
1743
139k
  if (i >= table_size)
1744
138k
    return;
1745
1746
765
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
765
      && default_alignment < alignment_table[i].default_alignment_min)
1748
0
    return;
1749
1750
765
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
765
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
765
      && default_alignment > alignment_table[i].default_alignment_max
1753
765
#endif
1754
765
      )
1755
0
    return;
1756
1757
765
  section->alignment_power = alignment_table[i].alignment_power;
1758
765
}
coff-stgo32.c:coff_set_custom_section_alignment
Line
Count
Source
1729
96.2k
{
1730
96.2k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
96.2k
  unsigned int i;
1732
1733
861k
  for (i = 0; i < table_size; ++i)
1734
766k
    {
1735
766k
      const char *secname = bfd_section_name (section);
1736
1737
766k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
766k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
766k
    : strncmp (alignment_table[i].name, secname,
1740
383k
         alignment_table[i].comparison_length) == 0)
1741
993
  break;
1742
766k
    }
1743
96.2k
  if (i >= table_size)
1744
95.2k
    return;
1745
1746
993
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
993
      && default_alignment < alignment_table[i].default_alignment_min)
1748
363
    return;
1749
1750
630
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
630
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
630
      && default_alignment > alignment_table[i].default_alignment_max
1753
630
#endif
1754
630
      )
1755
0
    return;
1756
1757
630
  section->alignment_power = alignment_table[i].alignment_power;
1758
630
}
coff-tic30.c:coff_set_custom_section_alignment
Line
Count
Source
1729
204k
{
1730
204k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
204k
  unsigned int i;
1732
1733
1.02M
  for (i = 0; i < table_size; ++i)
1734
817k
    {
1735
817k
      const char *secname = bfd_section_name (section);
1736
1737
817k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
817k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
817k
    : strncmp (alignment_table[i].name, secname,
1740
409k
         alignment_table[i].comparison_length) == 0)
1741
1.11k
  break;
1742
817k
    }
1743
204k
  if (i >= table_size)
1744
203k
    return;
1745
1746
1.11k
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
1.11k
      && default_alignment < alignment_table[i].default_alignment_min)
1748
818
    return;
1749
1750
293
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
293
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
293
      && default_alignment > alignment_table[i].default_alignment_max
1753
293
#endif
1754
293
      )
1755
0
    return;
1756
1757
293
  section->alignment_power = alignment_table[i].alignment_power;
1758
293
}
Unexecuted instantiation: coff-tic4x.c:coff_set_custom_section_alignment
coff-tic54x.c:coff_set_custom_section_alignment
Line
Count
Source
1729
25.7k
{
1730
25.7k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
25.7k
  unsigned int i;
1732
1733
128k
  for (i = 0; i < table_size; ++i)
1734
102k
    {
1735
102k
      const char *secname = bfd_section_name (section);
1736
1737
102k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
102k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
102k
    : strncmp (alignment_table[i].name, secname,
1740
51.4k
         alignment_table[i].comparison_length) == 0)
1741
157
  break;
1742
102k
    }
1743
25.7k
  if (i >= table_size)
1744
25.5k
    return;
1745
1746
157
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
157
      && default_alignment < alignment_table[i].default_alignment_min)
1748
157
    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
36.2k
{
1730
36.2k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
36.2k
  unsigned int i;
1732
1733
180k
  for (i = 0; i < table_size; ++i)
1734
144k
    {
1735
144k
      const char *secname = bfd_section_name (section);
1736
1737
144k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
144k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
144k
    : strncmp (alignment_table[i].name, secname,
1740
72.5k
         alignment_table[i].comparison_length) == 0)
1741
236
  break;
1742
144k
    }
1743
36.2k
  if (i >= table_size)
1744
36.0k
    return;
1745
1746
236
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
236
      && default_alignment < alignment_table[i].default_alignment_min)
1748
236
    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
44.1k
{
1730
44.1k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
44.1k
  unsigned int i;
1732
1733
219k
  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
88.1k
         alignment_table[i].comparison_length) == 0)
1741
321
  break;
1742
176k
    }
1743
44.1k
  if (i >= table_size)
1744
43.8k
    return;
1745
1746
321
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
321
      && default_alignment < alignment_table[i].default_alignment_min)
1748
211
    return;
1749
1750
110
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
110
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
110
      && default_alignment > alignment_table[i].default_alignment_max
1753
110
#endif
1754
110
      )
1755
0
    return;
1756
1757
110
  section->alignment_power = alignment_table[i].alignment_power;
1758
110
}
pe-arm-wince.c:coff_set_custom_section_alignment
Line
Count
Source
1729
3.21k
{
1730
3.21k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
3.21k
  unsigned int i;
1732
1733
44.7k
  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
19.1k
         alignment_table[i].comparison_length) == 0)
1741
49
  break;
1742
41.5k
    }
1743
3.21k
  if (i >= table_size)
1744
3.16k
    return;
1745
1746
49
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
49
      && default_alignment < alignment_table[i].default_alignment_min)
1748
12
    return;
1749
1750
37
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
37
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
37
      && default_alignment > alignment_table[i].default_alignment_max
1753
37
#endif
1754
37
      )
1755
0
    return;
1756
1757
37
  section->alignment_power = alignment_table[i].alignment_power;
1758
37
}
pe-arm.c:coff_set_custom_section_alignment
Line
Count
Source
1729
3.21k
{
1730
3.21k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
3.21k
  unsigned int i;
1732
1733
44.7k
  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
19.1k
         alignment_table[i].comparison_length) == 0)
1741
49
  break;
1742
41.5k
    }
1743
3.21k
  if (i >= table_size)
1744
3.16k
    return;
1745
1746
49
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
49
      && default_alignment < alignment_table[i].default_alignment_min)
1748
12
    return;
1749
1750
37
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
37
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
37
      && default_alignment > alignment_table[i].default_alignment_max
1753
37
#endif
1754
37
      )
1755
0
    return;
1756
1757
37
  section->alignment_power = alignment_table[i].alignment_power;
1758
37
}
pe-i386.c:coff_set_custom_section_alignment
Line
Count
Source
1729
5.14k
{
1730
5.14k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
5.14k
  unsigned int i;
1732
1733
51.0k
  for (i = 0; i < table_size; ++i)
1734
45.9k
    {
1735
45.9k
      const char *secname = bfd_section_name (section);
1736
1737
45.9k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
45.9k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
45.9k
    : strncmp (alignment_table[i].name, secname,
1740
30.7k
         alignment_table[i].comparison_length) == 0)
1741
91
  break;
1742
45.9k
    }
1743
5.14k
  if (i >= table_size)
1744
5.05k
    return;
1745
1746
91
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
91
      && default_alignment < alignment_table[i].default_alignment_min)
1748
33
    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
}
pe-mcore.c:coff_set_custom_section_alignment
Line
Count
Source
1729
2.62k
{
1730
2.62k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
2.62k
  unsigned int i;
1732
1733
12.9k
  for (i = 0; i < table_size; ++i)
1734
10.3k
    {
1735
10.3k
      const char *secname = bfd_section_name (section);
1736
1737
10.3k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
10.3k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
10.3k
    : strncmp (alignment_table[i].name, secname,
1740
5.23k
         alignment_table[i].comparison_length) == 0)
1741
44
  break;
1742
10.3k
    }
1743
2.62k
  if (i >= table_size)
1744
2.57k
    return;
1745
1746
44
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
44
      && default_alignment < alignment_table[i].default_alignment_min)
1748
33
    return;
1749
1750
11
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
11
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
11
      && default_alignment > alignment_table[i].default_alignment_max
1753
11
#endif
1754
11
      )
1755
0
    return;
1756
1757
11
  section->alignment_power = alignment_table[i].alignment_power;
1758
11
}
pe-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
3.29k
{
1730
3.29k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
3.29k
  unsigned int i;
1732
1733
16.2k
  for (i = 0; i < table_size; ++i)
1734
13.0k
    {
1735
13.0k
      const char *secname = bfd_section_name (section);
1736
1737
13.0k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
13.0k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
13.0k
    : strncmp (alignment_table[i].name, secname,
1740
6.56k
         alignment_table[i].comparison_length) == 0)
1741
61
  break;
1742
13.0k
    }
1743
3.29k
  if (i >= table_size)
1744
3.23k
    return;
1745
1746
61
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
61
      && default_alignment < alignment_table[i].default_alignment_min)
1748
44
    return;
1749
1750
17
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
17
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
17
      && default_alignment > alignment_table[i].default_alignment_max
1753
17
#endif
1754
17
      )
1755
0
    return;
1756
1757
17
  section->alignment_power = alignment_table[i].alignment_power;
1758
17
}
pei-arm-wince.c:coff_set_custom_section_alignment
Line
Count
Source
1729
5.10k
{
1730
5.10k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
5.10k
  unsigned int i;
1732
1733
65.4k
  for (i = 0; i < table_size; ++i)
1734
60.5k
    {
1735
60.5k
      const char *secname = bfd_section_name (section);
1736
1737
60.5k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
60.5k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
60.5k
    : strncmp (alignment_table[i].name, secname,
1740
25.1k
         alignment_table[i].comparison_length) == 0)
1741
130
  break;
1742
60.5k
    }
1743
5.10k
  if (i >= table_size)
1744
4.97k
    return;
1745
1746
130
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
130
      && default_alignment < alignment_table[i].default_alignment_min)
1748
41
    return;
1749
1750
89
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
89
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
89
      && default_alignment > alignment_table[i].default_alignment_max
1753
89
#endif
1754
89
      )
1755
0
    return;
1756
1757
89
  section->alignment_power = alignment_table[i].alignment_power;
1758
89
}
pei-arm.c:coff_set_custom_section_alignment
Line
Count
Source
1729
6.25k
{
1730
6.25k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
6.25k
  unsigned int i;
1732
1733
80.4k
  for (i = 0; i < table_size; ++i)
1734
74.2k
    {
1735
74.2k
      const char *secname = bfd_section_name (section);
1736
1737
74.2k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
74.2k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
74.2k
    : strncmp (alignment_table[i].name, secname,
1740
30.8k
         alignment_table[i].comparison_length) == 0)
1741
138
  break;
1742
74.2k
    }
1743
6.25k
  if (i >= table_size)
1744
6.11k
    return;
1745
1746
138
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
138
      && default_alignment < alignment_table[i].default_alignment_min)
1748
41
    return;
1749
1750
97
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
97
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
97
      && default_alignment > alignment_table[i].default_alignment_max
1753
97
#endif
1754
97
      )
1755
0
    return;
1756
1757
97
  section->alignment_power = alignment_table[i].alignment_power;
1758
97
}
pei-mcore.c:coff_set_custom_section_alignment
Line
Count
Source
1729
4.29k
{
1730
4.29k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
4.29k
  unsigned int i;
1732
1733
21.4k
  for (i = 0; i < table_size; ++i)
1734
17.1k
    {
1735
17.1k
      const char *secname = bfd_section_name (section);
1736
1737
17.1k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
17.1k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
17.1k
    : strncmp (alignment_table[i].name, secname,
1740
8.59k
         alignment_table[i].comparison_length) == 0)
1741
15
  break;
1742
17.1k
    }
1743
4.29k
  if (i >= table_size)
1744
4.28k
    return;
1745
1746
15
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
15
      && default_alignment < alignment_table[i].default_alignment_min)
1748
12
    return;
1749
1750
3
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
3
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
3
      && default_alignment > alignment_table[i].default_alignment_max
1753
3
#endif
1754
3
      )
1755
0
    return;
1756
1757
3
  section->alignment_power = alignment_table[i].alignment_power;
1758
3
}
pei-sh.c:coff_set_custom_section_alignment
Line
Count
Source
1729
3.45k
{
1730
3.45k
  const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1731
3.45k
  unsigned int i;
1732
1733
17.2k
  for (i = 0; i < table_size; ++i)
1734
13.7k
    {
1735
13.7k
      const char *secname = bfd_section_name (section);
1736
1737
13.7k
      if (alignment_table[i].comparison_length == (unsigned int) -1
1738
13.7k
    ? strcmp (alignment_table[i].name, secname) == 0
1739
13.7k
    : strncmp (alignment_table[i].name, secname,
1740
6.91k
         alignment_table[i].comparison_length) == 0)
1741
30
  break;
1742
13.7k
    }
1743
3.45k
  if (i >= table_size)
1744
3.42k
    return;
1745
1746
30
  if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
1747
30
      && default_alignment < alignment_table[i].default_alignment_min)
1748
23
    return;
1749
1750
7
  if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
1751
7
#if COFF_DEFAULT_SECTION_ALIGNMENT_POWER != 0
1752
7
      && default_alignment > alignment_table[i].default_alignment_max
1753
7
#endif
1754
7
      )
1755
0
    return;
1756
1757
7
  section->alignment_power = alignment_table[i].alignment_power;
1758
7
}
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.00M
{
1790
2.00M
  combined_entry_type *native;
1791
2.00M
  size_t amt;
1792
2.00M
  unsigned char sclass = C_STAT;
1793
1794
2.00M
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
#ifdef RS6000COFF_C
1797
575k
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
575k
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
463
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
574k
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
574k
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
249
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
574k
  else
1804
574k
    {
1805
574k
      int i;
1806
1807
6.89M
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
6.31M
  if (strcmp (bfd_section_name (section),
1809
6.31M
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
38
    {
1811
38
      section->alignment_power = 0;
1812
38
      sclass = C_DWARF;
1813
38
      break;
1814
38
    }
1815
574k
    }
1816
#endif
1817
1818
  /* Set up the section symbol.  */
1819
2.00M
  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.00M
  amt = sizeof (combined_entry_type) * 10;
1828
2.00M
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
2.00M
  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.00M
  native->is_sym = true;
1839
2.00M
  native->u.syment.n_type = T_NULL;
1840
2.00M
  native->u.syment.n_sclass = sclass;
1841
1842
2.00M
  coffsymbol (section->symbol)->native = native;
1843
1844
2.00M
  coff_set_custom_section_alignment (abfd, section,
1845
2.00M
             coff_section_alignment_table,
1846
2.00M
             coff_section_alignment_table_size);
1847
1848
2.00M
  return true;
1849
2.00M
}
pei-i386.c:coff_new_section_hook
Line
Count
Source
1789
6.35k
{
1790
6.35k
  combined_entry_type *native;
1791
6.35k
  size_t amt;
1792
6.35k
  unsigned char sclass = C_STAT;
1793
1794
6.35k
  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.35k
  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.35k
  amt = sizeof (combined_entry_type) * 10;
1828
6.35k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
6.35k
  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.35k
  native->is_sym = true;
1839
6.35k
  native->u.syment.n_type = T_NULL;
1840
6.35k
  native->u.syment.n_sclass = sclass;
1841
1842
6.35k
  coffsymbol (section->symbol)->native = native;
1843
1844
6.35k
  coff_set_custom_section_alignment (abfd, section,
1845
6.35k
             coff_section_alignment_table,
1846
6.35k
             coff_section_alignment_table_size);
1847
1848
6.35k
  return true;
1849
6.35k
}
pe-x86_64.c:coff_new_section_hook
Line
Count
Source
1789
5.65k
{
1790
5.65k
  combined_entry_type *native;
1791
5.65k
  size_t amt;
1792
5.65k
  unsigned char sclass = C_STAT;
1793
1794
5.65k
  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
5.65k
  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
5.65k
  amt = sizeof (combined_entry_type) * 10;
1828
5.65k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
5.65k
  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
5.65k
  native->is_sym = true;
1839
5.65k
  native->u.syment.n_type = T_NULL;
1840
5.65k
  native->u.syment.n_sclass = sclass;
1841
1842
5.65k
  coffsymbol (section->symbol)->native = native;
1843
1844
5.65k
  coff_set_custom_section_alignment (abfd, section,
1845
5.65k
             coff_section_alignment_table,
1846
5.65k
             coff_section_alignment_table_size);
1847
1848
5.65k
  return true;
1849
5.65k
}
pei-x86_64.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
}
coff-x86_64.c:coff_new_section_hook
Line
Count
Source
1789
163k
{
1790
163k
  combined_entry_type *native;
1791
163k
  size_t amt;
1792
163k
  unsigned char sclass = C_STAT;
1793
1794
163k
  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
163k
  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
163k
  amt = sizeof (combined_entry_type) * 10;
1828
163k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
163k
  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
163k
  native->is_sym = true;
1839
163k
  native->u.syment.n_type = T_NULL;
1840
163k
  native->u.syment.n_sclass = sclass;
1841
1842
163k
  coffsymbol (section->symbol)->native = native;
1843
1844
163k
  coff_set_custom_section_alignment (abfd, section,
1845
163k
             coff_section_alignment_table,
1846
163k
             coff_section_alignment_table_size);
1847
1848
163k
  return true;
1849
163k
}
coff64-rs6000.c:coff_new_section_hook
Line
Count
Source
1789
84.1k
{
1790
84.1k
  combined_entry_type *native;
1791
84.1k
  size_t amt;
1792
84.1k
  unsigned char sclass = C_STAT;
1793
1794
84.1k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
84.1k
#ifdef RS6000COFF_C
1797
84.1k
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
84.1k
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
134
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
83.9k
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
83.9k
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
45
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
83.9k
  else
1804
83.9k
    {
1805
83.9k
      int i;
1806
1807
1.00M
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
923k
  if (strcmp (bfd_section_name (section),
1809
923k
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
14
    {
1811
14
      section->alignment_power = 0;
1812
14
      sclass = C_DWARF;
1813
14
      break;
1814
14
    }
1815
83.9k
    }
1816
84.1k
#endif
1817
1818
  /* Set up the section symbol.  */
1819
84.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
84.1k
  amt = sizeof (combined_entry_type) * 10;
1828
84.1k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
84.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
84.1k
  native->is_sym = true;
1839
84.1k
  native->u.syment.n_type = T_NULL;
1840
84.1k
  native->u.syment.n_sclass = sclass;
1841
1842
84.1k
  coffsymbol (section->symbol)->native = native;
1843
1844
84.1k
  coff_set_custom_section_alignment (abfd, section,
1845
84.1k
             coff_section_alignment_table,
1846
84.1k
             coff_section_alignment_table_size);
1847
1848
84.1k
  return true;
1849
84.1k
}
pe-aarch64.c:coff_new_section_hook
Line
Count
Source
1789
4.34k
{
1790
4.34k
  combined_entry_type *native;
1791
4.34k
  size_t amt;
1792
4.34k
  unsigned char sclass = C_STAT;
1793
1794
4.34k
  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.34k
  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.34k
  amt = sizeof (combined_entry_type) * 10;
1828
4.34k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
4.34k
  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.34k
  native->is_sym = true;
1839
4.34k
  native->u.syment.n_type = T_NULL;
1840
4.34k
  native->u.syment.n_sclass = sclass;
1841
1842
4.34k
  coffsymbol (section->symbol)->native = native;
1843
1844
4.34k
  coff_set_custom_section_alignment (abfd, section,
1845
4.34k
             coff_section_alignment_table,
1846
4.34k
             coff_section_alignment_table_size);
1847
1848
4.34k
  return true;
1849
4.34k
}
pei-aarch64.c:coff_new_section_hook
Line
Count
Source
1789
8.07k
{
1790
8.07k
  combined_entry_type *native;
1791
8.07k
  size_t amt;
1792
8.07k
  unsigned char sclass = C_STAT;
1793
1794
8.07k
  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.07k
  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.07k
  amt = sizeof (combined_entry_type) * 10;
1828
8.07k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
8.07k
  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.07k
  native->is_sym = true;
1839
8.07k
  native->u.syment.n_type = T_NULL;
1840
8.07k
  native->u.syment.n_sclass = sclass;
1841
1842
8.07k
  coffsymbol (section->symbol)->native = native;
1843
1844
8.07k
  coff_set_custom_section_alignment (abfd, section,
1845
8.07k
             coff_section_alignment_table,
1846
8.07k
             coff_section_alignment_table_size);
1847
1848
8.07k
  return true;
1849
8.07k
}
pei-ia64.c:coff_new_section_hook
Line
Count
Source
1789
4.91k
{
1790
4.91k
  combined_entry_type *native;
1791
4.91k
  size_t amt;
1792
4.91k
  unsigned char sclass = C_STAT;
1793
1794
4.91k
  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.91k
  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.91k
  amt = sizeof (combined_entry_type) * 10;
1828
4.91k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
4.91k
  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.91k
  native->is_sym = true;
1839
4.91k
  native->u.syment.n_type = T_NULL;
1840
4.91k
  native->u.syment.n_sclass = sclass;
1841
1842
4.91k
  coffsymbol (section->symbol)->native = native;
1843
1844
4.91k
  coff_set_custom_section_alignment (abfd, section,
1845
4.91k
             coff_section_alignment_table,
1846
4.91k
             coff_section_alignment_table_size);
1847
1848
4.91k
  return true;
1849
4.91k
}
pei-loongarch64.c:coff_new_section_hook
Line
Count
Source
1789
6.28k
{
1790
6.28k
  combined_entry_type *native;
1791
6.28k
  size_t amt;
1792
6.28k
  unsigned char sclass = C_STAT;
1793
1794
6.28k
  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.28k
  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.28k
  amt = sizeof (combined_entry_type) * 10;
1828
6.28k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
6.28k
  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.28k
  native->is_sym = true;
1839
6.28k
  native->u.syment.n_type = T_NULL;
1840
6.28k
  native->u.syment.n_sclass = sclass;
1841
1842
6.28k
  coffsymbol (section->symbol)->native = native;
1843
1844
6.28k
  coff_set_custom_section_alignment (abfd, section,
1845
6.28k
             coff_section_alignment_table,
1846
6.28k
             coff_section_alignment_table_size);
1847
1848
6.28k
  return true;
1849
6.28k
}
cf-i386lynx.c:coff_new_section_hook
Line
Count
Source
1789
281k
{
1790
281k
  combined_entry_type *native;
1791
281k
  size_t amt;
1792
281k
  unsigned char sclass = C_STAT;
1793
1794
281k
  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
281k
  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
281k
  amt = sizeof (combined_entry_type) * 10;
1828
281k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
281k
  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
281k
  native->is_sym = true;
1839
281k
  native->u.syment.n_type = T_NULL;
1840
281k
  native->u.syment.n_sclass = sclass;
1841
1842
281k
  coffsymbol (section->symbol)->native = native;
1843
1844
281k
  coff_set_custom_section_alignment (abfd, section,
1845
281k
             coff_section_alignment_table,
1846
281k
             coff_section_alignment_table_size);
1847
1848
281k
  return true;
1849
281k
}
coff-go32.c:coff_new_section_hook
Line
Count
Source
1789
166k
{
1790
166k
  combined_entry_type *native;
1791
166k
  size_t amt;
1792
166k
  unsigned char sclass = C_STAT;
1793
1794
166k
  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
166k
  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
166k
  amt = sizeof (combined_entry_type) * 10;
1828
166k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
166k
  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
166k
  native->is_sym = true;
1839
166k
  native->u.syment.n_type = T_NULL;
1840
166k
  native->u.syment.n_sclass = sclass;
1841
1842
166k
  coffsymbol (section->symbol)->native = native;
1843
1844
166k
  coff_set_custom_section_alignment (abfd, section,
1845
166k
             coff_section_alignment_table,
1846
166k
             coff_section_alignment_table_size);
1847
1848
166k
  return true;
1849
166k
}
coff-i386.c:coff_new_section_hook
Line
Count
Source
1789
190k
{
1790
190k
  combined_entry_type *native;
1791
190k
  size_t amt;
1792
190k
  unsigned char sclass = C_STAT;
1793
1794
190k
  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
190k
  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
190k
  amt = sizeof (combined_entry_type) * 10;
1828
190k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
190k
  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
190k
  native->is_sym = true;
1839
190k
  native->u.syment.n_type = T_NULL;
1840
190k
  native->u.syment.n_sclass = sclass;
1841
1842
190k
  coffsymbol (section->symbol)->native = native;
1843
1844
190k
  coff_set_custom_section_alignment (abfd, section,
1845
190k
             coff_section_alignment_table,
1846
190k
             coff_section_alignment_table_size);
1847
1848
190k
  return true;
1849
190k
}
coff-rs6000.c:coff_new_section_hook
Line
Count
Source
1789
490k
{
1790
490k
  combined_entry_type *native;
1791
490k
  size_t amt;
1792
490k
  unsigned char sclass = C_STAT;
1793
1794
490k
  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
1795
1796
490k
#ifdef RS6000COFF_C
1797
490k
  if (bfd_xcoff_text_align_power (abfd) != 0
1798
490k
      && strcmp (bfd_section_name (section), ".text") == 0)
1799
329
    section->alignment_power = bfd_xcoff_text_align_power (abfd);
1800
490k
  else if (bfd_xcoff_data_align_power (abfd) != 0
1801
490k
      && strcmp (bfd_section_name (section), ".data") == 0)
1802
204
    section->alignment_power = bfd_xcoff_data_align_power (abfd);
1803
490k
  else
1804
490k
    {
1805
490k
      int i;
1806
1807
5.88M
      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
1808
5.39M
  if (strcmp (bfd_section_name (section),
1809
5.39M
        xcoff_dwsect_names[i].xcoff_name) == 0)
1810
24
    {
1811
24
      section->alignment_power = 0;
1812
24
      sclass = C_DWARF;
1813
24
      break;
1814
24
    }
1815
490k
    }
1816
490k
#endif
1817
1818
  /* Set up the section symbol.  */
1819
490k
  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
490k
  amt = sizeof (combined_entry_type) * 10;
1828
490k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
490k
  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
490k
  native->is_sym = true;
1839
490k
  native->u.syment.n_type = T_NULL;
1840
490k
  native->u.syment.n_sclass = sclass;
1841
1842
490k
  coffsymbol (section->symbol)->native = native;
1843
1844
490k
  coff_set_custom_section_alignment (abfd, section,
1845
490k
             coff_section_alignment_table,
1846
490k
             coff_section_alignment_table_size);
1847
1848
490k
  return true;
1849
490k
}
coff-sh.c:coff_new_section_hook
Line
Count
Source
1789
139k
{
1790
139k
  combined_entry_type *native;
1791
139k
  size_t amt;
1792
139k
  unsigned char sclass = C_STAT;
1793
1794
139k
  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
139k
  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
139k
  amt = sizeof (combined_entry_type) * 10;
1828
139k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
139k
  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
139k
  native->is_sym = true;
1839
139k
  native->u.syment.n_type = T_NULL;
1840
139k
  native->u.syment.n_sclass = sclass;
1841
1842
139k
  coffsymbol (section->symbol)->native = native;
1843
1844
139k
  coff_set_custom_section_alignment (abfd, section,
1845
139k
             coff_section_alignment_table,
1846
139k
             coff_section_alignment_table_size);
1847
1848
139k
  return true;
1849
139k
}
coff-stgo32.c:coff_new_section_hook
Line
Count
Source
1789
96.2k
{
1790
96.2k
  combined_entry_type *native;
1791
96.2k
  size_t amt;
1792
96.2k
  unsigned char sclass = C_STAT;
1793
1794
96.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
96.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
96.2k
  amt = sizeof (combined_entry_type) * 10;
1828
96.2k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
96.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
96.2k
  native->is_sym = true;
1839
96.2k
  native->u.syment.n_type = T_NULL;
1840
96.2k
  native->u.syment.n_sclass = sclass;
1841
1842
96.2k
  coffsymbol (section->symbol)->native = native;
1843
1844
96.2k
  coff_set_custom_section_alignment (abfd, section,
1845
96.2k
             coff_section_alignment_table,
1846
96.2k
             coff_section_alignment_table_size);
1847
1848
96.2k
  return true;
1849
96.2k
}
coff-tic30.c:coff_new_section_hook
Line
Count
Source
1789
204k
{
1790
204k
  combined_entry_type *native;
1791
204k
  size_t amt;
1792
204k
  unsigned char sclass = C_STAT;
1793
1794
204k
  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
204k
  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
204k
  amt = sizeof (combined_entry_type) * 10;
1828
204k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
204k
  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
204k
  native->is_sym = true;
1839
204k
  native->u.syment.n_type = T_NULL;
1840
204k
  native->u.syment.n_sclass = sclass;
1841
1842
204k
  coffsymbol (section->symbol)->native = native;
1843
1844
204k
  coff_set_custom_section_alignment (abfd, section,
1845
204k
             coff_section_alignment_table,
1846
204k
             coff_section_alignment_table_size);
1847
1848
204k
  return true;
1849
204k
}
Unexecuted instantiation: coff-tic4x.c:coff_new_section_hook
coff-tic54x.c:coff_new_section_hook
Line
Count
Source
1789
25.7k
{
1790
25.7k
  combined_entry_type *native;
1791
25.7k
  size_t amt;
1792
25.7k
  unsigned char sclass = C_STAT;
1793
1794
25.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
25.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
25.7k
  amt = sizeof (combined_entry_type) * 10;
1828
25.7k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
25.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
25.7k
  native->is_sym = true;
1839
25.7k
  native->u.syment.n_type = T_NULL;
1840
25.7k
  native->u.syment.n_sclass = sclass;
1841
1842
25.7k
  coffsymbol (section->symbol)->native = native;
1843
1844
25.7k
  coff_set_custom_section_alignment (abfd, section,
1845
25.7k
             coff_section_alignment_table,
1846
25.7k
             coff_section_alignment_table_size);
1847
1848
25.7k
  return true;
1849
25.7k
}
coff-z80.c:coff_new_section_hook
Line
Count
Source
1789
36.2k
{
1790
36.2k
  combined_entry_type *native;
1791
36.2k
  size_t amt;
1792
36.2k
  unsigned char sclass = C_STAT;
1793
1794
36.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
36.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
36.2k
  amt = sizeof (combined_entry_type) * 10;
1828
36.2k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
36.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
36.2k
  native->is_sym = true;
1839
36.2k
  native->u.syment.n_type = T_NULL;
1840
36.2k
  native->u.syment.n_sclass = sclass;
1841
1842
36.2k
  coffsymbol (section->symbol)->native = native;
1843
1844
36.2k
  coff_set_custom_section_alignment (abfd, section,
1845
36.2k
             coff_section_alignment_table,
1846
36.2k
             coff_section_alignment_table_size);
1847
1848
36.2k
  return true;
1849
36.2k
}
coff-z8k.c:coff_new_section_hook
Line
Count
Source
1789
44.1k
{
1790
44.1k
  combined_entry_type *native;
1791
44.1k
  size_t amt;
1792
44.1k
  unsigned char sclass = C_STAT;
1793
1794
44.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
44.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
44.1k
  amt = sizeof (combined_entry_type) * 10;
1828
44.1k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
44.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
44.1k
  native->is_sym = true;
1839
44.1k
  native->u.syment.n_type = T_NULL;
1840
44.1k
  native->u.syment.n_sclass = sclass;
1841
1842
44.1k
  coffsymbol (section->symbol)->native = native;
1843
1844
44.1k
  coff_set_custom_section_alignment (abfd, section,
1845
44.1k
             coff_section_alignment_table,
1846
44.1k
             coff_section_alignment_table_size);
1847
1848
44.1k
  return true;
1849
44.1k
}
pe-arm-wince.c:coff_new_section_hook
Line
Count
Source
1789
3.21k
{
1790
3.21k
  combined_entry_type *native;
1791
3.21k
  size_t amt;
1792
3.21k
  unsigned char sclass = C_STAT;
1793
1794
3.21k
  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.21k
  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.21k
  amt = sizeof (combined_entry_type) * 10;
1828
3.21k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
3.21k
  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.21k
  native->is_sym = true;
1839
3.21k
  native->u.syment.n_type = T_NULL;
1840
3.21k
  native->u.syment.n_sclass = sclass;
1841
1842
3.21k
  coffsymbol (section->symbol)->native = native;
1843
1844
3.21k
  coff_set_custom_section_alignment (abfd, section,
1845
3.21k
             coff_section_alignment_table,
1846
3.21k
             coff_section_alignment_table_size);
1847
1848
3.21k
  return true;
1849
3.21k
}
pe-arm.c:coff_new_section_hook
Line
Count
Source
1789
3.21k
{
1790
3.21k
  combined_entry_type *native;
1791
3.21k
  size_t amt;
1792
3.21k
  unsigned char sclass = C_STAT;
1793
1794
3.21k
  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.21k
  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.21k
  amt = sizeof (combined_entry_type) * 10;
1828
3.21k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
3.21k
  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.21k
  native->is_sym = true;
1839
3.21k
  native->u.syment.n_type = T_NULL;
1840
3.21k
  native->u.syment.n_sclass = sclass;
1841
1842
3.21k
  coffsymbol (section->symbol)->native = native;
1843
1844
3.21k
  coff_set_custom_section_alignment (abfd, section,
1845
3.21k
             coff_section_alignment_table,
1846
3.21k
             coff_section_alignment_table_size);
1847
1848
3.21k
  return true;
1849
3.21k
}
pe-i386.c:coff_new_section_hook
Line
Count
Source
1789
5.14k
{
1790
5.14k
  combined_entry_type *native;
1791
5.14k
  size_t amt;
1792
5.14k
  unsigned char sclass = C_STAT;
1793
1794
5.14k
  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
5.14k
  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
5.14k
  amt = sizeof (combined_entry_type) * 10;
1828
5.14k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
5.14k
  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
5.14k
  native->is_sym = true;
1839
5.14k
  native->u.syment.n_type = T_NULL;
1840
5.14k
  native->u.syment.n_sclass = sclass;
1841
1842
5.14k
  coffsymbol (section->symbol)->native = native;
1843
1844
5.14k
  coff_set_custom_section_alignment (abfd, section,
1845
5.14k
             coff_section_alignment_table,
1846
5.14k
             coff_section_alignment_table_size);
1847
1848
5.14k
  return true;
1849
5.14k
}
pe-mcore.c:coff_new_section_hook
Line
Count
Source
1789
2.62k
{
1790
2.62k
  combined_entry_type *native;
1791
2.62k
  size_t amt;
1792
2.62k
  unsigned char sclass = C_STAT;
1793
1794
2.62k
  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.62k
  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.62k
  amt = sizeof (combined_entry_type) * 10;
1828
2.62k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
2.62k
  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.62k
  native->is_sym = true;
1839
2.62k
  native->u.syment.n_type = T_NULL;
1840
2.62k
  native->u.syment.n_sclass = sclass;
1841
1842
2.62k
  coffsymbol (section->symbol)->native = native;
1843
1844
2.62k
  coff_set_custom_section_alignment (abfd, section,
1845
2.62k
             coff_section_alignment_table,
1846
2.62k
             coff_section_alignment_table_size);
1847
1848
2.62k
  return true;
1849
2.62k
}
pe-sh.c:coff_new_section_hook
Line
Count
Source
1789
3.29k
{
1790
3.29k
  combined_entry_type *native;
1791
3.29k
  size_t amt;
1792
3.29k
  unsigned char sclass = C_STAT;
1793
1794
3.29k
  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.29k
  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.29k
  amt = sizeof (combined_entry_type) * 10;
1828
3.29k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
3.29k
  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.29k
  native->is_sym = true;
1839
3.29k
  native->u.syment.n_type = T_NULL;
1840
3.29k
  native->u.syment.n_sclass = sclass;
1841
1842
3.29k
  coffsymbol (section->symbol)->native = native;
1843
1844
3.29k
  coff_set_custom_section_alignment (abfd, section,
1845
3.29k
             coff_section_alignment_table,
1846
3.29k
             coff_section_alignment_table_size);
1847
1848
3.29k
  return true;
1849
3.29k
}
pei-arm-wince.c:coff_new_section_hook
Line
Count
Source
1789
5.10k
{
1790
5.10k
  combined_entry_type *native;
1791
5.10k
  size_t amt;
1792
5.10k
  unsigned char sclass = C_STAT;
1793
1794
5.10k
  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
5.10k
  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
5.10k
  amt = sizeof (combined_entry_type) * 10;
1828
5.10k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
5.10k
  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
5.10k
  native->is_sym = true;
1839
5.10k
  native->u.syment.n_type = T_NULL;
1840
5.10k
  native->u.syment.n_sclass = sclass;
1841
1842
5.10k
  coffsymbol (section->symbol)->native = native;
1843
1844
5.10k
  coff_set_custom_section_alignment (abfd, section,
1845
5.10k
             coff_section_alignment_table,
1846
5.10k
             coff_section_alignment_table_size);
1847
1848
5.10k
  return true;
1849
5.10k
}
pei-arm.c:coff_new_section_hook
Line
Count
Source
1789
6.25k
{
1790
6.25k
  combined_entry_type *native;
1791
6.25k
  size_t amt;
1792
6.25k
  unsigned char sclass = C_STAT;
1793
1794
6.25k
  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.25k
  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.25k
  amt = sizeof (combined_entry_type) * 10;
1828
6.25k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
6.25k
  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.25k
  native->is_sym = true;
1839
6.25k
  native->u.syment.n_type = T_NULL;
1840
6.25k
  native->u.syment.n_sclass = sclass;
1841
1842
6.25k
  coffsymbol (section->symbol)->native = native;
1843
1844
6.25k
  coff_set_custom_section_alignment (abfd, section,
1845
6.25k
             coff_section_alignment_table,
1846
6.25k
             coff_section_alignment_table_size);
1847
1848
6.25k
  return true;
1849
6.25k
}
pei-mcore.c:coff_new_section_hook
Line
Count
Source
1789
4.29k
{
1790
4.29k
  combined_entry_type *native;
1791
4.29k
  size_t amt;
1792
4.29k
  unsigned char sclass = C_STAT;
1793
1794
4.29k
  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.29k
  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.29k
  amt = sizeof (combined_entry_type) * 10;
1828
4.29k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
4.29k
  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.29k
  native->is_sym = true;
1839
4.29k
  native->u.syment.n_type = T_NULL;
1840
4.29k
  native->u.syment.n_sclass = sclass;
1841
1842
4.29k
  coffsymbol (section->symbol)->native = native;
1843
1844
4.29k
  coff_set_custom_section_alignment (abfd, section,
1845
4.29k
             coff_section_alignment_table,
1846
4.29k
             coff_section_alignment_table_size);
1847
1848
4.29k
  return true;
1849
4.29k
}
pei-sh.c:coff_new_section_hook
Line
Count
Source
1789
3.45k
{
1790
3.45k
  combined_entry_type *native;
1791
3.45k
  size_t amt;
1792
3.45k
  unsigned char sclass = C_STAT;
1793
1794
3.45k
  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.45k
  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.45k
  amt = sizeof (combined_entry_type) * 10;
1828
3.45k
  native = (combined_entry_type *) bfd_zalloc (abfd, amt);
1829
3.45k
  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.45k
  native->is_sym = true;
1839
3.45k
  native->u.syment.n_type = T_NULL;
1840
3.45k
  native->u.syment.n_sclass = sclass;
1841
1842
3.45k
  coffsymbol (section->symbol)->native = native;
1843
1844
3.45k
  coff_set_custom_section_alignment (abfd, section,
1845
3.45k
             coff_section_alignment_table,
1846
3.45k
             coff_section_alignment_table_size);
1847
1848
3.45k
  return true;
1849
3.45k
}
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.0k
{
1860
62.0k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
62.0k
  unsigned int i;
1862
1863
62.0k
#ifdef COFF_DECODE_ALIGNMENT
1864
62.0k
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
62.0k
#endif
1866
62.0k
  section->alignment_power = i;
1867
1868
#ifdef coff_set_section_load_page
1869
25.7k
  coff_set_section_load_page (section, hdr->s_page);
1870
#endif
1871
62.0k
}
Unexecuted instantiation: coff-tic4x.c:coff_set_alignment_hook
coff-tic54x.c:coff_set_alignment_hook
Line
Count
Source
1859
25.7k
{
1860
25.7k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
25.7k
  unsigned int i;
1862
1863
25.7k
#ifdef COFF_DECODE_ALIGNMENT
1864
25.7k
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
25.7k
#endif
1866
25.7k
  section->alignment_power = i;
1867
1868
25.7k
#ifdef coff_set_section_load_page
1869
25.7k
  coff_set_section_load_page (section, hdr->s_page);
1870
25.7k
#endif
1871
25.7k
}
coff-z80.c:coff_set_alignment_hook
Line
Count
Source
1859
36.2k
{
1860
36.2k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1861
36.2k
  unsigned int i;
1862
1863
36.2k
#ifdef COFF_DECODE_ALIGNMENT
1864
36.2k
  i = COFF_DECODE_ALIGNMENT(hdr->s_flags);
1865
36.2k
#endif
1866
36.2k
  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
36.2k
}
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
74.9k
{
1881
74.9k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
74.9k
  size_t amt;
1883
74.9k
  unsigned int alignment_power_const
1884
74.9k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
74.9k
  switch (alignment_power_const)
1887
74.9k
    {
1888
2.42k
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
2.76k
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
3.80k
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
4.78k
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
10.1k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
10.6k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
14.9k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
15.5k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
18.4k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
19.1k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
20.3k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
21.3k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
23.0k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
24.3k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
24.3k
      section->alignment_power
1903
24.3k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
24.3k
      break;
1905
50.6k
    default:
1906
50.6k
      break;
1907
74.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
74.9k
  if (coff_section_data (abfd, section) == NULL)
1914
74.9k
    {
1915
74.9k
      amt = sizeof (struct coff_section_tdata);
1916
74.9k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
74.9k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
74.9k
    }
1921
1922
74.9k
  if (pei_section_data (abfd, section) == NULL)
1923
74.9k
    {
1924
74.9k
      amt = sizeof (struct pei_section_tdata);
1925
74.9k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
74.9k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
74.9k
    }
1930
74.9k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
74.9k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
74.9k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
74.9k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
7.85k
    {
1938
7.85k
      struct external_reloc dst;
1939
7.85k
      struct internal_reloc n;
1940
7.85k
      file_ptr oldpos = bfd_tell (abfd);
1941
7.85k
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
7.85k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
7.85k
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
3.73k
  return;
1947
1948
4.12k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
4.12k
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
4.12k
      if (n.r_vaddr < 0x10000)
1952
1.15k
  {
1953
1.15k
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
1.15k
    bfd_set_error (bfd_error_bad_value);
1955
1.15k
    return;
1956
1.15k
  }
1957
2.97k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
2.97k
      section->rel_filepos += relsz;
1959
2.97k
    }
1960
67.1k
  else if (hdr->s_nreloc == 0xffff)
1961
295
    _bfd_error_handler
1962
295
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
295
       abfd);
1964
74.9k
}
pei-i386.c:coff_set_alignment_hook
Line
Count
Source
1880
6.29k
{
1881
6.29k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
6.29k
  size_t amt;
1883
6.29k
  unsigned int alignment_power_const
1884
6.29k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
6.29k
  switch (alignment_power_const)
1887
6.29k
    {
1888
150
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
162
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
201
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
239
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
463
    case IMAGE_SCN_ALIGN_512BYTES:
1893
537
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.34k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.36k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.49k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.50k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.59k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.64k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.67k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.71k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.71k
      section->alignment_power
1903
1.71k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.71k
      break;
1905
4.58k
    default:
1906
4.58k
      break;
1907
6.29k
    }
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
6.29k
  if (coff_section_data (abfd, section) == NULL)
1914
6.29k
    {
1915
6.29k
      amt = sizeof (struct coff_section_tdata);
1916
6.29k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
6.29k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
6.29k
    }
1921
1922
6.29k
  if (pei_section_data (abfd, section) == NULL)
1923
6.29k
    {
1924
6.29k
      amt = sizeof (struct pei_section_tdata);
1925
6.29k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
6.29k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
6.29k
    }
1930
6.29k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
6.29k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
6.29k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
6.29k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
276
    {
1938
276
      struct external_reloc dst;
1939
276
      struct internal_reloc n;
1940
276
      file_ptr oldpos = bfd_tell (abfd);
1941
276
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
276
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
276
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
112
  return;
1947
1948
164
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
164
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
164
      if (n.r_vaddr < 0x10000)
1952
51
  {
1953
51
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
51
    bfd_set_error (bfd_error_bad_value);
1955
51
    return;
1956
51
  }
1957
113
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
113
      section->rel_filepos += relsz;
1959
113
    }
1960
6.02k
  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
6.29k
}
pe-x86_64.c:coff_set_alignment_hook
Line
Count
Source
1880
5.62k
{
1881
5.62k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
5.62k
  size_t amt;
1883
5.62k
  unsigned int alignment_power_const
1884
5.62k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
5.62k
  switch (alignment_power_const)
1887
5.62k
    {
1888
125
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
144
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
192
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
207
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
583
    case IMAGE_SCN_ALIGN_512BYTES:
1893
630
    case IMAGE_SCN_ALIGN_256BYTES:
1894
1.05k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.13k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.31k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.36k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.48k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.65k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.74k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.83k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.83k
      section->alignment_power
1903
1.83k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.83k
      break;
1905
3.78k
    default:
1906
3.78k
      break;
1907
5.62k
    }
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
5.62k
  if (coff_section_data (abfd, section) == NULL)
1914
5.62k
    {
1915
5.62k
      amt = sizeof (struct coff_section_tdata);
1916
5.62k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
5.62k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
5.62k
    }
1921
1922
5.62k
  if (pei_section_data (abfd, section) == NULL)
1923
5.62k
    {
1924
5.62k
      amt = sizeof (struct pei_section_tdata);
1925
5.62k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
5.62k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
5.62k
    }
1930
5.62k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
5.62k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
5.62k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
5.62k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
781
    {
1938
781
      struct external_reloc dst;
1939
781
      struct internal_reloc n;
1940
781
      file_ptr oldpos = bfd_tell (abfd);
1941
781
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
781
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
781
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
485
  return;
1947
1948
296
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
296
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
296
      if (n.r_vaddr < 0x10000)
1952
71
  {
1953
71
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
71
    bfd_set_error (bfd_error_bad_value);
1955
71
    return;
1956
71
  }
1957
225
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
225
      section->rel_filepos += relsz;
1959
225
    }
1960
4.84k
  else if (hdr->s_nreloc == 0xffff)
1961
121
    _bfd_error_handler
1962
121
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
121
       abfd);
1964
5.62k
}
pei-x86_64.c:coff_set_alignment_hook
Line
Count
Source
1880
3.75k
{
1881
3.75k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
3.75k
  size_t amt;
1883
3.75k
  unsigned int alignment_power_const
1884
3.75k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
3.75k
  switch (alignment_power_const)
1887
3.75k
    {
1888
246
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
272
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
348
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
397
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
693
    case IMAGE_SCN_ALIGN_512BYTES:
1893
694
    case IMAGE_SCN_ALIGN_256BYTES:
1894
863
    case IMAGE_SCN_ALIGN_128BYTES:
1895
877
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.00k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.05k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.15k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.23k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.29k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.39k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.39k
      section->alignment_power
1903
1.39k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.39k
      break;
1905
2.35k
    default:
1906
2.35k
      break;
1907
3.75k
    }
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.75k
  if (coff_section_data (abfd, section) == NULL)
1914
3.75k
    {
1915
3.75k
      amt = sizeof (struct coff_section_tdata);
1916
3.75k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
3.75k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
3.75k
    }
1921
1922
3.75k
  if (pei_section_data (abfd, section) == NULL)
1923
3.75k
    {
1924
3.75k
      amt = sizeof (struct pei_section_tdata);
1925
3.75k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
3.75k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
3.75k
    }
1930
3.75k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
3.75k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
3.75k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
3.75k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
352
    {
1938
352
      struct external_reloc dst;
1939
352
      struct internal_reloc n;
1940
352
      file_ptr oldpos = bfd_tell (abfd);
1941
352
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
352
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
352
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
167
  return;
1947
1948
185
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
185
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
185
      if (n.r_vaddr < 0x10000)
1952
64
  {
1953
64
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
64
    bfd_set_error (bfd_error_bad_value);
1955
64
    return;
1956
64
  }
1957
121
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
121
      section->rel_filepos += relsz;
1959
121
    }
1960
3.40k
  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.75k
}
pe-aarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
4.33k
{
1881
4.33k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
4.33k
  size_t amt;
1883
4.33k
  unsigned int alignment_power_const
1884
4.33k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
4.33k
  switch (alignment_power_const)
1887
4.33k
    {
1888
154
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
216
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
236
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
367
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
426
    case IMAGE_SCN_ALIGN_512BYTES:
1893
500
    case IMAGE_SCN_ALIGN_256BYTES:
1894
914
    case IMAGE_SCN_ALIGN_128BYTES:
1895
982
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.04k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.08k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.12k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.16k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.20k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.29k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.29k
      section->alignment_power
1903
1.29k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.29k
      break;
1905
3.04k
    default:
1906
3.04k
      break;
1907
4.33k
    }
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.33k
  if (coff_section_data (abfd, section) == NULL)
1914
4.33k
    {
1915
4.33k
      amt = sizeof (struct coff_section_tdata);
1916
4.33k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
4.33k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
4.33k
    }
1921
1922
4.33k
  if (pei_section_data (abfd, section) == NULL)
1923
4.33k
    {
1924
4.33k
      amt = sizeof (struct pei_section_tdata);
1925
4.33k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
4.33k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
4.33k
    }
1930
4.33k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
4.33k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
4.33k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
4.33k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
680
    {
1938
680
      struct external_reloc dst;
1939
680
      struct internal_reloc n;
1940
680
      file_ptr oldpos = bfd_tell (abfd);
1941
680
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
680
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
680
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
356
  return;
1947
1948
324
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
324
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
324
      if (n.r_vaddr < 0x10000)
1952
120
  {
1953
120
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
120
    bfd_set_error (bfd_error_bad_value);
1955
120
    return;
1956
120
  }
1957
204
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
204
      section->rel_filepos += relsz;
1959
204
    }
1960
3.65k
  else if (hdr->s_nreloc == 0xffff)
1961
18
    _bfd_error_handler
1962
18
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
18
       abfd);
1964
4.33k
}
pei-aarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
7.84k
{
1881
7.84k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
7.84k
  size_t amt;
1883
7.84k
  unsigned int alignment_power_const
1884
7.84k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
7.84k
  switch (alignment_power_const)
1887
7.84k
    {
1888
69
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
88
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
122
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
188
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
469
    case IMAGE_SCN_ALIGN_512BYTES:
1893
492
    case IMAGE_SCN_ALIGN_256BYTES:
1894
983
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.02k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.52k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.57k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.64k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.73k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.81k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.97k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.97k
      section->alignment_power
1903
1.97k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.97k
      break;
1905
5.86k
    default:
1906
5.86k
      break;
1907
7.84k
    }
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
7.84k
  if (coff_section_data (abfd, section) == NULL)
1914
7.84k
    {
1915
7.84k
      amt = sizeof (struct coff_section_tdata);
1916
7.84k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
7.84k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
7.84k
    }
1921
1922
7.84k
  if (pei_section_data (abfd, section) == NULL)
1923
7.84k
    {
1924
7.84k
      amt = sizeof (struct pei_section_tdata);
1925
7.84k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
7.84k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
7.84k
    }
1930
7.84k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
7.84k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
7.84k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
7.84k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
440
    {
1938
440
      struct external_reloc dst;
1939
440
      struct internal_reloc n;
1940
440
      file_ptr oldpos = bfd_tell (abfd);
1941
440
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
440
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
440
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
200
  return;
1947
1948
240
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
240
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
240
      if (n.r_vaddr < 0x10000)
1952
103
  {
1953
103
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
103
    bfd_set_error (bfd_error_bad_value);
1955
103
    return;
1956
103
  }
1957
137
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
137
      section->rel_filepos += relsz;
1959
137
    }
1960
7.40k
  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
7.84k
}
pei-ia64.c:coff_set_alignment_hook
Line
Count
Source
1880
4.86k
{
1881
4.86k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
4.86k
  size_t amt;
1883
4.86k
  unsigned int alignment_power_const
1884
4.86k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
4.86k
  switch (alignment_power_const)
1887
4.86k
    {
1888
52
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
80
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
333
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
451
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
584
    case IMAGE_SCN_ALIGN_512BYTES:
1893
609
    case IMAGE_SCN_ALIGN_256BYTES:
1894
786
    case IMAGE_SCN_ALIGN_128BYTES:
1895
820
    case IMAGE_SCN_ALIGN_64BYTES:
1896
940
    case IMAGE_SCN_ALIGN_32BYTES:
1897
972
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.01k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.06k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.11k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.30k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.30k
      section->alignment_power
1903
1.30k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.30k
      break;
1905
3.55k
    default:
1906
3.55k
      break;
1907
4.86k
    }
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.86k
  if (coff_section_data (abfd, section) == NULL)
1914
4.86k
    {
1915
4.86k
      amt = sizeof (struct coff_section_tdata);
1916
4.86k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
4.86k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
4.86k
    }
1921
1922
4.86k
  if (pei_section_data (abfd, section) == NULL)
1923
4.86k
    {
1924
4.86k
      amt = sizeof (struct pei_section_tdata);
1925
4.86k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
4.86k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
4.86k
    }
1930
4.86k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
4.86k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
4.86k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
4.86k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
506
    {
1938
506
      struct external_reloc dst;
1939
506
      struct internal_reloc n;
1940
506
      file_ptr oldpos = bfd_tell (abfd);
1941
506
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
506
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
506
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
216
  return;
1947
1948
290
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
290
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
290
      if (n.r_vaddr < 0x10000)
1952
118
  {
1953
118
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
118
    bfd_set_error (bfd_error_bad_value);
1955
118
    return;
1956
118
  }
1957
172
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
172
      section->rel_filepos += relsz;
1959
172
    }
1960
4.35k
  else if (hdr->s_nreloc == 0xffff)
1961
0
    _bfd_error_handler
1962
0
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
0
       abfd);
1964
4.86k
}
pei-loongarch64.c:coff_set_alignment_hook
Line
Count
Source
1880
6.09k
{
1881
6.09k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
6.09k
  size_t amt;
1883
6.09k
  unsigned int alignment_power_const
1884
6.09k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
6.09k
  switch (alignment_power_const)
1887
6.09k
    {
1888
354
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
378
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
610
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
685
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
2.47k
    case IMAGE_SCN_ALIGN_512BYTES:
1893
2.49k
    case IMAGE_SCN_ALIGN_256BYTES:
1894
2.57k
    case IMAGE_SCN_ALIGN_128BYTES:
1895
2.65k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
2.74k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
2.80k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
2.83k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
2.93k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
3.27k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
3.33k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
3.33k
      section->alignment_power
1903
3.33k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
3.33k
      break;
1905
2.76k
    default:
1906
2.76k
      break;
1907
6.09k
    }
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
6.09k
  if (coff_section_data (abfd, section) == NULL)
1914
6.09k
    {
1915
6.09k
      amt = sizeof (struct coff_section_tdata);
1916
6.09k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
6.09k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
6.09k
    }
1921
1922
6.09k
  if (pei_section_data (abfd, section) == NULL)
1923
6.09k
    {
1924
6.09k
      amt = sizeof (struct pei_section_tdata);
1925
6.09k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
6.09k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
6.09k
    }
1930
6.09k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
6.09k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
6.09k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
6.09k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
596
    {
1938
596
      struct external_reloc dst;
1939
596
      struct internal_reloc n;
1940
596
      file_ptr oldpos = bfd_tell (abfd);
1941
596
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
596
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
596
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
280
  return;
1947
1948
316
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
316
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
316
      if (n.r_vaddr < 0x10000)
1952
78
  {
1953
78
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
78
    bfd_set_error (bfd_error_bad_value);
1955
78
    return;
1956
78
  }
1957
238
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
238
      section->rel_filepos += relsz;
1959
238
    }
1960
5.50k
  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
6.09k
}
pe-arm-wince.c:coff_set_alignment_hook
Line
Count
Source
1880
3.20k
{
1881
3.20k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
3.20k
  size_t amt;
1883
3.20k
  unsigned int alignment_power_const
1884
3.20k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
3.20k
  switch (alignment_power_const)
1887
3.20k
    {
1888
26
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
52
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
90
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
116
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
484
    case IMAGE_SCN_ALIGN_512BYTES:
1893
496
    case IMAGE_SCN_ALIGN_256BYTES:
1894
607
    case IMAGE_SCN_ALIGN_128BYTES:
1895
633
    case IMAGE_SCN_ALIGN_64BYTES:
1896
777
    case IMAGE_SCN_ALIGN_32BYTES:
1897
798
    case IMAGE_SCN_ALIGN_16BYTES:
1898
835
    case IMAGE_SCN_ALIGN_8BYTES:
1899
866
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.06k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.09k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.09k
      section->alignment_power
1903
1.09k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.09k
      break;
1905
2.10k
    default:
1906
2.10k
      break;
1907
3.20k
    }
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.20k
  if (coff_section_data (abfd, section) == NULL)
1914
3.20k
    {
1915
3.20k
      amt = sizeof (struct coff_section_tdata);
1916
3.20k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
3.20k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
3.20k
    }
1921
1922
3.20k
  if (pei_section_data (abfd, section) == NULL)
1923
3.20k
    {
1924
3.20k
      amt = sizeof (struct pei_section_tdata);
1925
3.20k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
3.20k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
3.20k
    }
1930
3.20k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
3.20k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
3.20k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
3.20k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
420
    {
1938
420
      struct external_reloc dst;
1939
420
      struct internal_reloc n;
1940
420
      file_ptr oldpos = bfd_tell (abfd);
1941
420
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
420
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
420
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
215
  return;
1947
1948
205
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
205
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
205
      if (n.r_vaddr < 0x10000)
1952
39
  {
1953
39
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
39
    bfd_set_error (bfd_error_bad_value);
1955
39
    return;
1956
39
  }
1957
166
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
166
      section->rel_filepos += relsz;
1959
166
    }
1960
2.78k
  else if (hdr->s_nreloc == 0xffff)
1961
27
    _bfd_error_handler
1962
27
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
27
       abfd);
1964
3.20k
}
pe-arm.c:coff_set_alignment_hook
Line
Count
Source
1880
3.20k
{
1881
3.20k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
3.20k
  size_t amt;
1883
3.20k
  unsigned int alignment_power_const
1884
3.20k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
3.20k
  switch (alignment_power_const)
1887
3.20k
    {
1888
26
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
52
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
90
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
116
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
484
    case IMAGE_SCN_ALIGN_512BYTES:
1893
496
    case IMAGE_SCN_ALIGN_256BYTES:
1894
607
    case IMAGE_SCN_ALIGN_128BYTES:
1895
633
    case IMAGE_SCN_ALIGN_64BYTES:
1896
777
    case IMAGE_SCN_ALIGN_32BYTES:
1897
798
    case IMAGE_SCN_ALIGN_16BYTES:
1898
835
    case IMAGE_SCN_ALIGN_8BYTES:
1899
866
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.06k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.09k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.09k
      section->alignment_power
1903
1.09k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.09k
      break;
1905
2.10k
    default:
1906
2.10k
      break;
1907
3.20k
    }
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.20k
  if (coff_section_data (abfd, section) == NULL)
1914
3.20k
    {
1915
3.20k
      amt = sizeof (struct coff_section_tdata);
1916
3.20k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
3.20k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
3.20k
    }
1921
1922
3.20k
  if (pei_section_data (abfd, section) == NULL)
1923
3.20k
    {
1924
3.20k
      amt = sizeof (struct pei_section_tdata);
1925
3.20k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
3.20k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
3.20k
    }
1930
3.20k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
3.20k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
3.20k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
3.20k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
420
    {
1938
420
      struct external_reloc dst;
1939
420
      struct internal_reloc n;
1940
420
      file_ptr oldpos = bfd_tell (abfd);
1941
420
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
420
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
420
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
215
  return;
1947
1948
205
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
205
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
205
      if (n.r_vaddr < 0x10000)
1952
39
  {
1953
39
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
39
    bfd_set_error (bfd_error_bad_value);
1955
39
    return;
1956
39
  }
1957
166
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
166
      section->rel_filepos += relsz;
1959
166
    }
1960
2.78k
  else if (hdr->s_nreloc == 0xffff)
1961
27
    _bfd_error_handler
1962
27
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
27
       abfd);
1964
3.20k
}
pe-i386.c:coff_set_alignment_hook
Line
Count
Source
1880
5.13k
{
1881
5.13k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
5.13k
  size_t amt;
1883
5.13k
  unsigned int alignment_power_const
1884
5.13k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
5.13k
  switch (alignment_power_const)
1887
5.13k
    {
1888
241
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
274
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
322
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
395
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
673
    case IMAGE_SCN_ALIGN_512BYTES:
1893
743
    case IMAGE_SCN_ALIGN_256BYTES:
1894
931
    case IMAGE_SCN_ALIGN_128BYTES:
1895
994
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.12k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.15k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.26k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.31k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.51k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.67k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.67k
      section->alignment_power
1903
1.67k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.67k
      break;
1905
3.45k
    default:
1906
3.45k
      break;
1907
5.13k
    }
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
5.13k
  if (coff_section_data (abfd, section) == NULL)
1914
5.13k
    {
1915
5.13k
      amt = sizeof (struct coff_section_tdata);
1916
5.13k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
5.13k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
5.13k
    }
1921
1922
5.13k
  if (pei_section_data (abfd, section) == NULL)
1923
5.13k
    {
1924
5.13k
      amt = sizeof (struct pei_section_tdata);
1925
5.13k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
5.13k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
5.13k
    }
1930
5.13k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
5.13k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
5.13k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
5.13k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
688
    {
1938
688
      struct external_reloc dst;
1939
688
      struct internal_reloc n;
1940
688
      file_ptr oldpos = bfd_tell (abfd);
1941
688
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
688
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
688
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
432
  return;
1947
1948
256
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
256
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
256
      if (n.r_vaddr < 0x10000)
1952
96
  {
1953
96
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
96
    bfd_set_error (bfd_error_bad_value);
1955
96
    return;
1956
96
  }
1957
160
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
160
      section->rel_filepos += relsz;
1959
160
    }
1960
4.44k
  else if (hdr->s_nreloc == 0xffff)
1961
54
    _bfd_error_handler
1962
54
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
54
       abfd);
1964
5.13k
}
pe-mcore.c:coff_set_alignment_hook
Line
Count
Source
1880
2.61k
{
1881
2.61k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
2.61k
  size_t amt;
1883
2.61k
  unsigned int alignment_power_const
1884
2.61k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
2.61k
  switch (alignment_power_const)
1887
2.61k
    {
1888
339
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
346
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
381
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
501
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
585
    case IMAGE_SCN_ALIGN_512BYTES:
1893
604
    case IMAGE_SCN_ALIGN_256BYTES:
1894
666
    case IMAGE_SCN_ALIGN_128BYTES:
1895
681
    case IMAGE_SCN_ALIGN_64BYTES:
1896
823
    case IMAGE_SCN_ALIGN_32BYTES:
1897
832
    case IMAGE_SCN_ALIGN_16BYTES:
1898
864
    case IMAGE_SCN_ALIGN_8BYTES:
1899
910
    case IMAGE_SCN_ALIGN_4BYTES:
1900
971
    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
1.59k
    default:
1906
1.59k
      break;
1907
2.61k
    }
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.61k
  if (coff_section_data (abfd, section) == NULL)
1914
2.61k
    {
1915
2.61k
      amt = sizeof (struct coff_section_tdata);
1916
2.61k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
2.61k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
2.61k
    }
1921
1922
2.61k
  if (pei_section_data (abfd, section) == NULL)
1923
2.61k
    {
1924
2.61k
      amt = sizeof (struct pei_section_tdata);
1925
2.61k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
2.61k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
2.61k
    }
1930
2.61k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
2.61k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
2.61k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
2.61k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
347
    {
1938
347
      struct external_reloc dst;
1939
347
      struct internal_reloc n;
1940
347
      file_ptr oldpos = bfd_tell (abfd);
1941
347
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
347
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
347
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
138
  return;
1947
1948
209
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
209
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
209
      if (n.r_vaddr < 0x10000)
1952
57
  {
1953
57
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
57
    bfd_set_error (bfd_error_bad_value);
1955
57
    return;
1956
57
  }
1957
152
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
152
      section->rel_filepos += relsz;
1959
152
    }
1960
2.26k
  else if (hdr->s_nreloc == 0xffff)
1961
15
    _bfd_error_handler
1962
15
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
15
       abfd);
1964
2.61k
}
pe-sh.c:coff_set_alignment_hook
Line
Count
Source
1880
3.23k
{
1881
3.23k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
3.23k
  size_t amt;
1883
3.23k
  unsigned int alignment_power_const
1884
3.23k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
3.23k
  switch (alignment_power_const)
1887
3.23k
    {
1888
187
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
207
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
226
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
282
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
308
    case IMAGE_SCN_ALIGN_512BYTES:
1893
369
    case IMAGE_SCN_ALIGN_256BYTES:
1894
525
    case IMAGE_SCN_ALIGN_128BYTES:
1895
557
    case IMAGE_SCN_ALIGN_64BYTES:
1896
628
    case IMAGE_SCN_ALIGN_32BYTES:
1897
641
    case IMAGE_SCN_ALIGN_16BYTES:
1898
805
    case IMAGE_SCN_ALIGN_8BYTES:
1899
844
    case IMAGE_SCN_ALIGN_4BYTES:
1900
887
    case IMAGE_SCN_ALIGN_2BYTES:
1901
953
    case IMAGE_SCN_ALIGN_1BYTES:
1902
953
      section->alignment_power
1903
953
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
953
      break;
1905
2.28k
    default:
1906
2.28k
      break;
1907
3.23k
    }
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.23k
  if (coff_section_data (abfd, section) == NULL)
1914
3.23k
    {
1915
3.23k
      amt = sizeof (struct coff_section_tdata);
1916
3.23k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
3.23k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
3.23k
    }
1921
1922
3.23k
  if (pei_section_data (abfd, section) == NULL)
1923
3.23k
    {
1924
3.23k
      amt = sizeof (struct pei_section_tdata);
1925
3.23k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
3.23k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
3.23k
    }
1930
3.23k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
3.23k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
3.23k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
3.23k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
412
    {
1938
412
      struct external_reloc dst;
1939
412
      struct internal_reloc n;
1940
412
      file_ptr oldpos = bfd_tell (abfd);
1941
412
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
412
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
412
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
248
  return;
1947
1948
164
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
164
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
164
      if (n.r_vaddr < 0x10000)
1952
23
  {
1953
23
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
23
    bfd_set_error (bfd_error_bad_value);
1955
23
    return;
1956
23
  }
1957
141
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
141
      section->rel_filepos += relsz;
1959
141
    }
1960
2.82k
  else if (hdr->s_nreloc == 0xffff)
1961
33
    _bfd_error_handler
1962
33
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
1963
33
       abfd);
1964
3.23k
}
pei-arm-wince.c:coff_set_alignment_hook
Line
Count
Source
1880
5.00k
{
1881
5.00k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
5.00k
  size_t amt;
1883
5.00k
  unsigned int alignment_power_const
1884
5.00k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
5.00k
  switch (alignment_power_const)
1887
5.00k
    {
1888
74
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
82
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
129
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
152
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
321
    case IMAGE_SCN_ALIGN_512BYTES:
1893
340
    case IMAGE_SCN_ALIGN_256BYTES:
1894
603
    case IMAGE_SCN_ALIGN_128BYTES:
1895
626
    case IMAGE_SCN_ALIGN_64BYTES:
1896
738
    case IMAGE_SCN_ALIGN_32BYTES:
1897
789
    case IMAGE_SCN_ALIGN_16BYTES:
1898
942
    case IMAGE_SCN_ALIGN_8BYTES:
1899
996
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.10k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.16k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.16k
      section->alignment_power
1903
1.16k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.16k
      break;
1905
3.84k
    default:
1906
3.84k
      break;
1907
5.00k
    }
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
5.00k
  if (coff_section_data (abfd, section) == NULL)
1914
5.00k
    {
1915
5.00k
      amt = sizeof (struct coff_section_tdata);
1916
5.00k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
5.00k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
5.00k
    }
1921
1922
5.00k
  if (pei_section_data (abfd, section) == NULL)
1923
5.00k
    {
1924
5.00k
      amt = sizeof (struct pei_section_tdata);
1925
5.00k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
5.00k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
5.00k
    }
1930
5.00k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
5.00k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
5.00k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
5.00k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
504
    {
1938
504
      struct external_reloc dst;
1939
504
      struct internal_reloc n;
1940
504
      file_ptr oldpos = bfd_tell (abfd);
1941
504
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
504
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
504
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
159
  return;
1947
1948
345
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
345
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
345
      if (n.r_vaddr < 0x10000)
1952
79
  {
1953
79
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
79
    bfd_set_error (bfd_error_bad_value);
1955
79
    return;
1956
79
  }
1957
266
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
266
      section->rel_filepos += relsz;
1959
266
    }
1960
4.50k
  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
5.00k
}
pei-arm.c:coff_set_alignment_hook
Line
Count
Source
1880
6.15k
{
1881
6.15k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
6.15k
  size_t amt;
1883
6.15k
  unsigned int alignment_power_const
1884
6.15k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
6.15k
  switch (alignment_power_const)
1887
6.15k
    {
1888
88
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
100
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
159
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
187
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
791
    case IMAGE_SCN_ALIGN_512BYTES:
1893
804
    case IMAGE_SCN_ALIGN_256BYTES:
1894
975
    case IMAGE_SCN_ALIGN_128BYTES:
1895
1.01k
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.12k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.19k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.32k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.37k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.53k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.62k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.62k
      section->alignment_power
1903
1.62k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.62k
      break;
1905
4.52k
    default:
1906
4.52k
      break;
1907
6.15k
    }
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
6.15k
  if (coff_section_data (abfd, section) == NULL)
1914
6.15k
    {
1915
6.15k
      amt = sizeof (struct coff_section_tdata);
1916
6.15k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
6.15k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
6.15k
    }
1921
1922
6.15k
  if (pei_section_data (abfd, section) == NULL)
1923
6.15k
    {
1924
6.15k
      amt = sizeof (struct pei_section_tdata);
1925
6.15k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
6.15k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
6.15k
    }
1930
6.15k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
6.15k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
6.15k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
6.15k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
614
    {
1938
614
      struct external_reloc dst;
1939
614
      struct internal_reloc n;
1940
614
      file_ptr oldpos = bfd_tell (abfd);
1941
614
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
614
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
614
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
197
  return;
1947
1948
417
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
417
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
417
      if (n.r_vaddr < 0x10000)
1952
100
  {
1953
100
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
100
    bfd_set_error (bfd_error_bad_value);
1955
100
    return;
1956
100
  }
1957
317
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
317
      section->rel_filepos += relsz;
1959
317
    }
1960
5.53k
  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
6.15k
}
pei-mcore.c:coff_set_alignment_hook
Line
Count
Source
1880
4.25k
{
1881
4.25k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
4.25k
  size_t amt;
1883
4.25k
  unsigned int alignment_power_const
1884
4.25k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
4.25k
  switch (alignment_power_const)
1887
4.25k
    {
1888
38
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
45
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
67
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
172
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
280
    case IMAGE_SCN_ALIGN_512BYTES:
1893
293
    case IMAGE_SCN_ALIGN_256BYTES:
1894
572
    case IMAGE_SCN_ALIGN_128BYTES:
1895
602
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.33k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.51k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.55k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.59k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.61k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.63k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.63k
      section->alignment_power
1903
1.63k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.63k
      break;
1905
2.62k
    default:
1906
2.62k
      break;
1907
4.25k
    }
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.25k
  if (coff_section_data (abfd, section) == NULL)
1914
4.25k
    {
1915
4.25k
      amt = sizeof (struct coff_section_tdata);
1916
4.25k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
4.25k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
4.25k
    }
1921
1922
4.25k
  if (pei_section_data (abfd, section) == NULL)
1923
4.25k
    {
1924
4.25k
      amt = sizeof (struct pei_section_tdata);
1925
4.25k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
4.25k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
4.25k
    }
1930
4.25k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
4.25k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
4.25k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
4.25k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
519
    {
1938
519
      struct external_reloc dst;
1939
519
      struct internal_reloc n;
1940
519
      file_ptr oldpos = bfd_tell (abfd);
1941
519
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
519
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
519
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
176
  return;
1947
1948
343
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
343
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
343
      if (n.r_vaddr < 0x10000)
1952
54
  {
1953
54
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
54
    bfd_set_error (bfd_error_bad_value);
1955
54
    return;
1956
54
  }
1957
289
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
289
      section->rel_filepos += relsz;
1959
289
    }
1960
3.73k
  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
4.25k
}
pei-sh.c:coff_set_alignment_hook
Line
Count
Source
1880
3.39k
{
1881
3.39k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1882
3.39k
  size_t amt;
1883
3.39k
  unsigned int alignment_power_const
1884
3.39k
    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
1885
1886
3.39k
  switch (alignment_power_const)
1887
3.39k
    {
1888
255
    case IMAGE_SCN_ALIGN_8192BYTES:
1889
266
    case IMAGE_SCN_ALIGN_4096BYTES:
1890
301
    case IMAGE_SCN_ALIGN_2048BYTES:
1891
332
    case IMAGE_SCN_ALIGN_1024BYTES:
1892
559
    case IMAGE_SCN_ALIGN_512BYTES:
1893
580
    case IMAGE_SCN_ALIGN_256BYTES:
1894
951
    case IMAGE_SCN_ALIGN_128BYTES:
1895
964
    case IMAGE_SCN_ALIGN_64BYTES:
1896
1.03k
    case IMAGE_SCN_ALIGN_32BYTES:
1897
1.05k
    case IMAGE_SCN_ALIGN_16BYTES:
1898
1.08k
    case IMAGE_SCN_ALIGN_8BYTES:
1899
1.15k
    case IMAGE_SCN_ALIGN_4BYTES:
1900
1.20k
    case IMAGE_SCN_ALIGN_2BYTES:
1901
1.24k
    case IMAGE_SCN_ALIGN_1BYTES:
1902
1.24k
      section->alignment_power
1903
1.24k
  = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
1904
1.24k
      break;
1905
2.15k
    default:
1906
2.15k
      break;
1907
3.39k
    }
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.39k
  if (coff_section_data (abfd, section) == NULL)
1914
3.39k
    {
1915
3.39k
      amt = sizeof (struct coff_section_tdata);
1916
3.39k
      section->used_by_bfd = bfd_zalloc (abfd, amt);
1917
3.39k
      if (section->used_by_bfd == NULL)
1918
  /* FIXME: Return error.  */
1919
0
  abort ();
1920
3.39k
    }
1921
1922
3.39k
  if (pei_section_data (abfd, section) == NULL)
1923
3.39k
    {
1924
3.39k
      amt = sizeof (struct pei_section_tdata);
1925
3.39k
      coff_section_data (abfd, section)->tdata = bfd_zalloc (abfd, amt);
1926
3.39k
      if (coff_section_data (abfd, section)->tdata == NULL)
1927
  /* FIXME: Return error.  */
1928
0
  abort ();
1929
3.39k
    }
1930
3.39k
  pei_section_data (abfd, section)->virt_size = hdr->s_paddr;
1931
3.39k
  pei_section_data (abfd, section)->pe_flags = hdr->s_flags;
1932
1933
3.39k
  section->lma = hdr->s_vaddr;
1934
1935
  /* Check for extended relocs.  */
1936
3.39k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
1937
302
    {
1938
302
      struct external_reloc dst;
1939
302
      struct internal_reloc n;
1940
302
      file_ptr oldpos = bfd_tell (abfd);
1941
302
      bfd_size_type relsz = bfd_coff_relsz (abfd);
1942
1943
302
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
1944
0
  return;
1945
302
      if (bfd_read (& dst, relsz, abfd) != relsz)
1946
134
  return;
1947
1948
168
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
1949
168
      if (bfd_seek (abfd, oldpos, 0) != 0)
1950
0
  return;
1951
168
      if (n.r_vaddr < 0x10000)
1952
59
  {
1953
59
    _bfd_error_handler (_("%pB: overflow reloc count too small"), abfd);
1954
59
    bfd_set_error (bfd_error_bad_value);
1955
59
    return;
1956
59
  }
1957
109
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
1958
109
      section->rel_filepos += relsz;
1959
109
    }
1960
3.09k
  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.39k
}
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
575k
{
1978
575k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
575k
  asection *real_sec;
1980
1981
575k
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
473k
    return;
1983
1984
102k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
102k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
102k
  real_sec->reloc_count = hdr->s_paddr;
1989
102k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
102k
  if (!bfd_section_removed_from_list (abfd, section))
1992
102k
    {
1993
102k
      bfd_section_list_remove (abfd, section);
1994
102k
      --abfd->section_count;
1995
102k
    }
1996
102k
}
coff64-rs6000.c:coff_set_alignment_hook
Line
Count
Source
1977
84.1k
{
1978
84.1k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
84.1k
  asection *real_sec;
1980
1981
84.1k
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
69.2k
    return;
1983
1984
14.8k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
14.8k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
14.8k
  real_sec->reloc_count = hdr->s_paddr;
1989
14.8k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
14.8k
  if (!bfd_section_removed_from_list (abfd, section))
1992
14.8k
    {
1993
14.8k
      bfd_section_list_remove (abfd, section);
1994
14.8k
      --abfd->section_count;
1995
14.8k
    }
1996
14.8k
}
coff-rs6000.c:coff_set_alignment_hook
Line
Count
Source
1977
490k
{
1978
490k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
1979
490k
  asection *real_sec;
1980
1981
490k
  if ((hdr->s_flags & STYP_OVRFLO) == 0)
1982
403k
    return;
1983
1984
87.2k
  real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
1985
87.2k
  if (real_sec == NULL)
1986
0
    return;
1987
1988
87.2k
  real_sec->reloc_count = hdr->s_paddr;
1989
87.2k
  real_sec->lineno_count = hdr->s_vaddr;
1990
1991
87.2k
  if (!bfd_section_removed_from_list (abfd, section))
1992
87.2k
    {
1993
87.2k
      bfd_section_list_remove (abfd, section);
1994
87.2k
      --abfd->section_count;
1995
87.2k
    }
1996
87.2k
}
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
262k
{
2004
262k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
2005
2006
  /* Check for extended relocs.  */
2007
262k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
2008
72.9k
    {
2009
72.9k
      struct external_reloc dst;
2010
72.9k
      struct internal_reloc n;
2011
72.9k
      const file_ptr oldpos = bfd_tell (abfd);
2012
72.9k
      const bfd_size_type relsz = bfd_coff_relsz (abfd);
2013
2014
72.9k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
2015
0
  return;
2016
72.9k
      if (bfd_read (& dst, relsz, abfd) != relsz)
2017
56.5k
  return;
2018
2019
16.3k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
2020
16.3k
      if (bfd_seek (abfd, oldpos, 0) != 0)
2021
0
  return;
2022
16.3k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
2023
16.3k
      section->rel_filepos += relsz;
2024
16.3k
    }
2025
189k
  else if (hdr->s_nreloc == 0xffff)
2026
6.53k
    _bfd_error_handler
2027
6.53k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
2028
6.53k
       abfd);
2029
262k
}
coff-go32.c:coff_set_alignment_hook
Line
Count
Source
2003
166k
{
2004
166k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
2005
2006
  /* Check for extended relocs.  */
2007
166k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
2008
46.4k
    {
2009
46.4k
      struct external_reloc dst;
2010
46.4k
      struct internal_reloc n;
2011
46.4k
      const file_ptr oldpos = bfd_tell (abfd);
2012
46.4k
      const bfd_size_type relsz = bfd_coff_relsz (abfd);
2013
2014
46.4k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
2015
0
  return;
2016
46.4k
      if (bfd_read (& dst, relsz, abfd) != relsz)
2017
35.6k
  return;
2018
2019
10.7k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
2020
10.7k
      if (bfd_seek (abfd, oldpos, 0) != 0)
2021
0
  return;
2022
10.7k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
2023
10.7k
      section->rel_filepos += relsz;
2024
10.7k
    }
2025
119k
  else if (hdr->s_nreloc == 0xffff)
2026
3.92k
    _bfd_error_handler
2027
3.92k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
2028
3.92k
       abfd);
2029
166k
}
coff-stgo32.c:coff_set_alignment_hook
Line
Count
Source
2003
96.2k
{
2004
96.2k
  struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
2005
2006
  /* Check for extended relocs.  */
2007
96.2k
  if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL)
2008
26.5k
    {
2009
26.5k
      struct external_reloc dst;
2010
26.5k
      struct internal_reloc n;
2011
26.5k
      const file_ptr oldpos = bfd_tell (abfd);
2012
26.5k
      const bfd_size_type relsz = bfd_coff_relsz (abfd);
2013
2014
26.5k
      if (bfd_seek (abfd, hdr->s_relptr, 0) != 0)
2015
0
  return;
2016
26.5k
      if (bfd_read (& dst, relsz, abfd) != relsz)
2017
20.9k
  return;
2018
2019
5.54k
      bfd_coff_swap_reloc_in (abfd, &dst, &n);
2020
5.54k
      if (bfd_seek (abfd, oldpos, 0) != 0)
2021
0
  return;
2022
5.54k
      section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1;
2023
5.54k
      section->rel_filepos += relsz;
2024
5.54k
    }
2025
69.7k
  else if (hdr->s_nreloc == 0xffff)
2026
2.60k
    _bfd_error_handler
2027
2.60k
      (_("%pB: warning: claims to have 0xffff relocs, without overflow"),
2028
2.60k
       abfd);
2029
96.2k
}
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
1.02M
{
2038
1.02M
}
coff-x86_64.c:coff_set_alignment_hook
Line
Count
Source
2037
163k
{
2038
163k
}
cf-i386lynx.c:coff_set_alignment_hook
Line
Count
Source
2037
281k
{
2038
281k
}
coff-i386.c:coff_set_alignment_hook
Line
Count
Source
2037
190k
{
2038
190k
}
coff-sh.c:coff_set_alignment_hook
Line
Count
Source
2037
139k
{
2038
139k
}
coff-tic30.c:coff_set_alignment_hook
Line
Count
Source
2037
204k
{
2038
204k
}
coff-z8k.c:coff_set_alignment_hook
Line
Count
Source
2037
44.1k
{
2038
44.1k
}
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.11k
{
2050
3.11k
  coff_data_type *coff;
2051
3.11k
  size_t amt = sizeof (coff_data_type);
2052
2053
3.11k
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
3.11k
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
3.11k
  coff = coff_data (abfd);
2058
3.11k
  coff->symbols = NULL;
2059
3.11k
  coff->conversion_table = NULL;
2060
3.11k
  coff->raw_syments = NULL;
2061
3.11k
  coff->relocbase = 0;
2062
3.11k
  coff->local_toc_sym_map = 0;
2063
2064
3.11k
  bfd_coff_long_section_names (abfd)
2065
3.11k
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
3.11k
  return true;
2070
3.11k
}
coff-x86_64.c:coff_mkobject
Line
Count
Source
2049
600
{
2050
600
  coff_data_type *coff;
2051
600
  size_t amt = sizeof (coff_data_type);
2052
2053
600
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
600
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
600
  coff = coff_data (abfd);
2058
600
  coff->symbols = NULL;
2059
600
  coff->conversion_table = NULL;
2060
600
  coff->raw_syments = NULL;
2061
600
  coff->relocbase = 0;
2062
600
  coff->local_toc_sym_map = 0;
2063
2064
600
  bfd_coff_long_section_names (abfd)
2065
600
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
600
  return true;
2070
600
}
cf-i386lynx.c:coff_mkobject
Line
Count
Source
2049
809
{
2050
809
  coff_data_type *coff;
2051
809
  size_t amt = sizeof (coff_data_type);
2052
2053
809
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
809
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
809
  coff = coff_data (abfd);
2058
809
  coff->symbols = NULL;
2059
809
  coff->conversion_table = NULL;
2060
809
  coff->raw_syments = NULL;
2061
809
  coff->relocbase = 0;
2062
809
  coff->local_toc_sym_map = 0;
2063
2064
809
  bfd_coff_long_section_names (abfd)
2065
809
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
809
  return true;
2070
809
}
coff-i386.c:coff_mkobject
Line
Count
Source
2049
625
{
2050
625
  coff_data_type *coff;
2051
625
  size_t amt = sizeof (coff_data_type);
2052
2053
625
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
625
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
625
  coff = coff_data (abfd);
2058
625
  coff->symbols = NULL;
2059
625
  coff->conversion_table = NULL;
2060
625
  coff->raw_syments = NULL;
2061
625
  coff->relocbase = 0;
2062
625
  coff->local_toc_sym_map = 0;
2063
2064
625
  bfd_coff_long_section_names (abfd)
2065
625
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
625
  return true;
2070
625
}
coff-sh.c:coff_mkobject
Line
Count
Source
2049
467
{
2050
467
  coff_data_type *coff;
2051
467
  size_t amt = sizeof (coff_data_type);
2052
2053
467
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
467
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
467
  coff = coff_data (abfd);
2058
467
  coff->symbols = NULL;
2059
467
  coff->conversion_table = NULL;
2060
467
  coff->raw_syments = NULL;
2061
467
  coff->relocbase = 0;
2062
467
  coff->local_toc_sym_map = 0;
2063
2064
467
  bfd_coff_long_section_names (abfd)
2065
467
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
467
  return true;
2070
467
}
coff-tic30.c:coff_mkobject
Line
Count
Source
2049
183
{
2050
183
  coff_data_type *coff;
2051
183
  size_t amt = sizeof (coff_data_type);
2052
2053
183
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
183
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
183
  coff = coff_data (abfd);
2058
183
  coff->symbols = NULL;
2059
183
  coff->conversion_table = NULL;
2060
183
  coff->raw_syments = NULL;
2061
183
  coff->relocbase = 0;
2062
183
  coff->local_toc_sym_map = 0;
2063
2064
183
  bfd_coff_long_section_names (abfd)
2065
183
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
183
  return true;
2070
183
}
Unexecuted instantiation: coff-tic4x.c:coff_mkobject
coff-tic54x.c:coff_mkobject
Line
Count
Source
2049
143
{
2050
143
  coff_data_type *coff;
2051
143
  size_t amt = sizeof (coff_data_type);
2052
2053
143
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
143
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
143
  coff = coff_data (abfd);
2058
143
  coff->symbols = NULL;
2059
143
  coff->conversion_table = NULL;
2060
143
  coff->raw_syments = NULL;
2061
143
  coff->relocbase = 0;
2062
143
  coff->local_toc_sym_map = 0;
2063
2064
143
  bfd_coff_long_section_names (abfd)
2065
143
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
143
  return true;
2070
143
}
coff-z80.c:coff_mkobject
Line
Count
Source
2049
139
{
2050
139
  coff_data_type *coff;
2051
139
  size_t amt = sizeof (coff_data_type);
2052
2053
139
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
139
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
139
  coff = coff_data (abfd);
2058
139
  coff->symbols = NULL;
2059
139
  coff->conversion_table = NULL;
2060
139
  coff->raw_syments = NULL;
2061
139
  coff->relocbase = 0;
2062
139
  coff->local_toc_sym_map = 0;
2063
2064
139
  bfd_coff_long_section_names (abfd)
2065
139
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
139
  return true;
2070
139
}
coff-z8k.c:coff_mkobject
Line
Count
Source
2049
150
{
2050
150
  coff_data_type *coff;
2051
150
  size_t amt = sizeof (coff_data_type);
2052
2053
150
  abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
2054
150
  if (abfd->tdata.coff_obj_data == NULL)
2055
0
    return false;
2056
2057
150
  coff = coff_data (abfd);
2058
150
  coff->symbols = NULL;
2059
150
  coff->conversion_table = NULL;
2060
150
  coff->raw_syments = NULL;
2061
150
  coff->relocbase = 0;
2062
150
  coff->local_toc_sym_map = 0;
2063
2064
150
  bfd_coff_long_section_names (abfd)
2065
150
    = coff_backend_info (abfd)->_bfd_coff_long_section_names;
2066
2067
/*  make_abs_section(abfd);*/
2068
2069
150
  return true;
2070
150
}
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.73k
{
2081
4.73k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
4.73k
  coff_data_type *coff;
2083
2084
4.73k
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
4.73k
  coff = coff_data (abfd);
2088
2089
4.73k
  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.73k
  coff->local_n_btmask = N_BTMASK;
2095
4.73k
  coff->local_n_btshft = N_BTSHFT;
2096
4.73k
  coff->local_n_tmask = N_TMASK;
2097
4.73k
  coff->local_n_tshift = N_TSHIFT;
2098
4.73k
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
4.73k
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
4.73k
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
4.73k
  coff->timestamp = internal_f->f_timdat;
2103
2104
4.73k
  obj_raw_syment_count (abfd) =
2105
4.73k
    obj_conv_table_size (abfd) =
2106
4.73k
      internal_f->f_nsyms;
2107
2108
#ifdef RS6000COFF_C
2109
793
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
131
    abfd->flags |= DYNAMIC;
2111
793
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
206
    {
2113
206
      struct internal_aouthdr *internal_a =
2114
206
  (struct internal_aouthdr *) aouthdr;
2115
206
      struct xcoff_tdata *xcoff;
2116
2117
206
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
106
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
206
      xcoff->full_aouthdr = true;
2124
206
      xcoff->toc = internal_a->o_toc;
2125
206
      xcoff->sntoc = internal_a->o_sntoc;
2126
206
      xcoff->snentry = internal_a->o_snentry;
2127
206
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
206
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
206
      xcoff->modtype = internal_a->o_modtype;
2130
206
      xcoff->cputype = internal_a->o_cputype;
2131
206
      xcoff->maxdata = internal_a->o_maxdata;
2132
206
      xcoff->maxstack = internal_a->o_maxstack;
2133
206
    }
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.73k
  return coff;
2150
4.73k
}
coff-x86_64.c:coff_mkobject_hook
Line
Count
Source
2080
600
{
2081
600
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
600
  coff_data_type *coff;
2083
2084
600
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
600
  coff = coff_data (abfd);
2088
2089
600
  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
600
  coff->local_n_btmask = N_BTMASK;
2095
600
  coff->local_n_btshft = N_BTSHFT;
2096
600
  coff->local_n_tmask = N_TMASK;
2097
600
  coff->local_n_tshift = N_TSHIFT;
2098
600
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
600
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
600
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
600
  coff->timestamp = internal_f->f_timdat;
2103
2104
600
  obj_raw_syment_count (abfd) =
2105
600
    obj_conv_table_size (abfd) =
2106
600
      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
600
  return coff;
2150
600
}
coff64-rs6000.c:coff_mkobject_hook
Line
Count
Source
2080
371
{
2081
371
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
371
  coff_data_type *coff;
2083
2084
371
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
371
  coff = coff_data (abfd);
2088
2089
371
  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
371
  coff->local_n_btmask = N_BTMASK;
2095
371
  coff->local_n_btshft = N_BTSHFT;
2096
371
  coff->local_n_tmask = N_TMASK;
2097
371
  coff->local_n_tshift = N_TSHIFT;
2098
371
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
371
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
371
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
371
  coff->timestamp = internal_f->f_timdat;
2103
2104
371
  obj_raw_syment_count (abfd) =
2105
371
    obj_conv_table_size (abfd) =
2106
371
      internal_f->f_nsyms;
2107
2108
371
#ifdef RS6000COFF_C
2109
371
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
71
    abfd->flags |= DYNAMIC;
2111
371
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
106
    {
2113
106
      struct internal_aouthdr *internal_a =
2114
106
  (struct internal_aouthdr *) aouthdr;
2115
106
      struct xcoff_tdata *xcoff;
2116
2117
106
      xcoff = xcoff_data (abfd);
2118
106
# ifdef U803XTOCMAGIC
2119
106
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
      xcoff->xcoff64 = 0;
2122
# endif
2123
106
      xcoff->full_aouthdr = true;
2124
106
      xcoff->toc = internal_a->o_toc;
2125
106
      xcoff->sntoc = internal_a->o_sntoc;
2126
106
      xcoff->snentry = internal_a->o_snentry;
2127
106
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
106
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
106
      xcoff->modtype = internal_a->o_modtype;
2130
106
      xcoff->cputype = internal_a->o_cputype;
2131
106
      xcoff->maxdata = internal_a->o_maxdata;
2132
106
      xcoff->maxstack = internal_a->o_maxstack;
2133
106
    }
2134
371
#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
371
  return coff;
2150
371
}
cf-i386lynx.c:coff_mkobject_hook
Line
Count
Source
2080
809
{
2081
809
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
809
  coff_data_type *coff;
2083
2084
809
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
809
  coff = coff_data (abfd);
2088
2089
809
  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
809
  coff->local_n_btmask = N_BTMASK;
2095
809
  coff->local_n_btshft = N_BTSHFT;
2096
809
  coff->local_n_tmask = N_TMASK;
2097
809
  coff->local_n_tshift = N_TSHIFT;
2098
809
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
809
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
809
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
809
  coff->timestamp = internal_f->f_timdat;
2103
2104
809
  obj_raw_syment_count (abfd) =
2105
809
    obj_conv_table_size (abfd) =
2106
809
      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
809
  return coff;
2150
809
}
coff-go32.c:coff_mkobject_hook
Line
Count
Source
2080
625
{
2081
625
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
625
  coff_data_type *coff;
2083
2084
625
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
625
  coff = coff_data (abfd);
2088
2089
625
  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
625
  coff->local_n_btmask = N_BTMASK;
2095
625
  coff->local_n_btshft = N_BTSHFT;
2096
625
  coff->local_n_tmask = N_TMASK;
2097
625
  coff->local_n_tshift = N_TSHIFT;
2098
625
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
625
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
625
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
625
  coff->timestamp = internal_f->f_timdat;
2103
2104
625
  obj_raw_syment_count (abfd) =
2105
625
    obj_conv_table_size (abfd) =
2106
625
      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
625
  return coff;
2150
625
}
coff-i386.c:coff_mkobject_hook
Line
Count
Source
2080
625
{
2081
625
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
625
  coff_data_type *coff;
2083
2084
625
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
625
  coff = coff_data (abfd);
2088
2089
625
  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
625
  coff->local_n_btmask = N_BTMASK;
2095
625
  coff->local_n_btshft = N_BTSHFT;
2096
625
  coff->local_n_tmask = N_TMASK;
2097
625
  coff->local_n_tshift = N_TSHIFT;
2098
625
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
625
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
625
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
625
  coff->timestamp = internal_f->f_timdat;
2103
2104
625
  obj_raw_syment_count (abfd) =
2105
625
    obj_conv_table_size (abfd) =
2106
625
      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
625
  return coff;
2150
625
}
coff-rs6000.c:coff_mkobject_hook
Line
Count
Source
2080
422
{
2081
422
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
422
  coff_data_type *coff;
2083
2084
422
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
422
  coff = coff_data (abfd);
2088
2089
422
  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
422
  coff->local_n_btmask = N_BTMASK;
2095
422
  coff->local_n_btshft = N_BTSHFT;
2096
422
  coff->local_n_tmask = N_TMASK;
2097
422
  coff->local_n_tshift = N_TSHIFT;
2098
422
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
422
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
422
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
422
  coff->timestamp = internal_f->f_timdat;
2103
2104
422
  obj_raw_syment_count (abfd) =
2105
422
    obj_conv_table_size (abfd) =
2106
422
      internal_f->f_nsyms;
2107
2108
422
#ifdef RS6000COFF_C
2109
422
  if ((internal_f->f_flags & F_SHROBJ) != 0)
2110
60
    abfd->flags |= DYNAMIC;
2111
422
  if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd))
2112
100
    {
2113
100
      struct internal_aouthdr *internal_a =
2114
100
  (struct internal_aouthdr *) aouthdr;
2115
100
      struct xcoff_tdata *xcoff;
2116
2117
100
      xcoff = xcoff_data (abfd);
2118
# ifdef U803XTOCMAGIC
2119
      xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;
2120
# else
2121
100
      xcoff->xcoff64 = 0;
2122
100
# endif
2123
100
      xcoff->full_aouthdr = true;
2124
100
      xcoff->toc = internal_a->o_toc;
2125
100
      xcoff->sntoc = internal_a->o_sntoc;
2126
100
      xcoff->snentry = internal_a->o_snentry;
2127
100
      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
2128
100
      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
2129
100
      xcoff->modtype = internal_a->o_modtype;
2130
100
      xcoff->cputype = internal_a->o_cputype;
2131
100
      xcoff->maxdata = internal_a->o_maxdata;
2132
100
      xcoff->maxstack = internal_a->o_maxstack;
2133
100
    }
2134
422
#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
422
  return coff;
2150
422
}
coff-sh.c:coff_mkobject_hook
Line
Count
Source
2080
467
{
2081
467
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
467
  coff_data_type *coff;
2083
2084
467
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
467
  coff = coff_data (abfd);
2088
2089
467
  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
467
  coff->local_n_btmask = N_BTMASK;
2095
467
  coff->local_n_btshft = N_BTSHFT;
2096
467
  coff->local_n_tmask = N_TMASK;
2097
467
  coff->local_n_tshift = N_TSHIFT;
2098
467
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
467
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
467
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
467
  coff->timestamp = internal_f->f_timdat;
2103
2104
467
  obj_raw_syment_count (abfd) =
2105
467
    obj_conv_table_size (abfd) =
2106
467
      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
467
  return coff;
2150
467
}
coff-stgo32.c:coff_mkobject_hook
Line
Count
Source
2080
200
{
2081
200
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
200
  coff_data_type *coff;
2083
2084
200
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
200
  coff = coff_data (abfd);
2088
2089
200
  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
200
  coff->local_n_btmask = N_BTMASK;
2095
200
  coff->local_n_btshft = N_BTSHFT;
2096
200
  coff->local_n_tmask = N_TMASK;
2097
200
  coff->local_n_tshift = N_TSHIFT;
2098
200
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
200
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
200
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
200
  coff->timestamp = internal_f->f_timdat;
2103
2104
200
  obj_raw_syment_count (abfd) =
2105
200
    obj_conv_table_size (abfd) =
2106
200
      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
200
  return coff;
2150
200
}
coff-tic30.c:coff_mkobject_hook
Line
Count
Source
2080
183
{
2081
183
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
183
  coff_data_type *coff;
2083
2084
183
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
183
  coff = coff_data (abfd);
2088
2089
183
  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
183
  coff->local_n_btmask = N_BTMASK;
2095
183
  coff->local_n_btshft = N_BTSHFT;
2096
183
  coff->local_n_tmask = N_TMASK;
2097
183
  coff->local_n_tshift = N_TSHIFT;
2098
183
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
183
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
183
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
183
  coff->timestamp = internal_f->f_timdat;
2103
2104
183
  obj_raw_syment_count (abfd) =
2105
183
    obj_conv_table_size (abfd) =
2106
183
      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
183
  return coff;
2150
183
}
Unexecuted instantiation: coff-tic4x.c:coff_mkobject_hook
coff-tic54x.c:coff_mkobject_hook
Line
Count
Source
2080
143
{
2081
143
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
143
  coff_data_type *coff;
2083
2084
143
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
143
  coff = coff_data (abfd);
2088
2089
143
  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
143
  coff->local_n_btmask = N_BTMASK;
2095
143
  coff->local_n_btshft = N_BTSHFT;
2096
143
  coff->local_n_tmask = N_TMASK;
2097
143
  coff->local_n_tshift = N_TSHIFT;
2098
143
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
143
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
143
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
143
  coff->timestamp = internal_f->f_timdat;
2103
2104
143
  obj_raw_syment_count (abfd) =
2105
143
    obj_conv_table_size (abfd) =
2106
143
      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
143
  return coff;
2150
143
}
coff-z80.c:coff_mkobject_hook
Line
Count
Source
2080
139
{
2081
139
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
139
  coff_data_type *coff;
2083
2084
139
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
139
  coff = coff_data (abfd);
2088
2089
139
  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
139
  coff->local_n_btmask = N_BTMASK;
2095
139
  coff->local_n_btshft = N_BTSHFT;
2096
139
  coff->local_n_tmask = N_TMASK;
2097
139
  coff->local_n_tshift = N_TSHIFT;
2098
139
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
139
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
139
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
139
  coff->timestamp = internal_f->f_timdat;
2103
2104
139
  obj_raw_syment_count (abfd) =
2105
139
    obj_conv_table_size (abfd) =
2106
139
      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
139
  return coff;
2150
139
}
coff-z8k.c:coff_mkobject_hook
Line
Count
Source
2080
150
{
2081
150
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2082
150
  coff_data_type *coff;
2083
2084
150
  if (! coff_mkobject (abfd))
2085
0
    return NULL;
2086
2087
150
  coff = coff_data (abfd);
2088
2089
150
  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
150
  coff->local_n_btmask = N_BTMASK;
2095
150
  coff->local_n_btshft = N_BTSHFT;
2096
150
  coff->local_n_tmask = N_TMASK;
2097
150
  coff->local_n_tshift = N_TSHIFT;
2098
150
  coff->local_symesz = bfd_coff_symesz (abfd);
2099
150
  coff->local_auxesz = bfd_coff_auxesz (abfd);
2100
150
  coff->local_linesz = bfd_coff_linesz (abfd);
2101
2102
150
  coff->timestamp = internal_f->f_timdat;
2103
2104
150
  obj_raw_syment_count (abfd) =
2105
150
    obj_conv_table_size (abfd) =
2106
150
      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
150
  return coff;
2150
150
}
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
11.9k
{
2163
11.9k
  unsigned long machine;
2164
11.9k
  enum bfd_architecture arch;
2165
11.9k
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
11.9k
  machine = 0;
2169
11.9k
  switch (internal_f->f_magic)
2170
11.9k
    {
2171
#ifdef I386MAGIC
2172
2.46k
    case I386MAGIC:
2173
2.56k
    case I386PTXMAGIC:
2174
2.62k
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
3.26k
    case LYNXCOFFMAGIC:
2176
3.36k
    case I386_APPLE_MAGIC:
2177
3.37k
    case I386_FREEBSD_MAGIC:
2178
3.37k
    case I386_LINUX_MAGIC:
2179
3.49k
    case I386_NETBSD_MAGIC:
2180
3.49k
      arch = bfd_arch_i386;
2181
3.49k
      break;
2182
0
#endif
2183
#ifdef AMD64MAGIC
2184
621
    case AMD64MAGIC:
2185
1.90k
    case AMD64_APPLE_MAGIC:
2186
1.92k
    case AMD64_FREEBSD_MAGIC:
2187
1.95k
    case AMD64_LINUX_MAGIC:
2188
1.97k
    case AMD64_NETBSD_MAGIC:
2189
1.97k
      arch = bfd_arch_i386;
2190
1.97k
      machine = bfd_mach_x86_64;
2191
1.97k
      break;
2192
0
#endif
2193
#ifdef IA64MAGIC
2194
366
    case IA64MAGIC:
2195
366
      arch = bfd_arch_ia64;
2196
366
      break;
2197
0
#endif
2198
#ifdef ARMMAGIC
2199
997
    case ARMMAGIC:
2200
1.52k
    case ARMPEMAGIC:
2201
1.64k
    case THUMBPEMAGIC:
2202
1.64k
      arch = bfd_arch_arm;
2203
1.64k
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
1.64k
      if (machine == bfd_mach_arm_unknown)
2205
1.64k
  {
2206
1.64k
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
1.64k
      {
2208
261
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
122
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
83
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
546
      default:
2212
686
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
158
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
173
      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
166
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
1.64k
      }
2222
1.64k
  }
2223
1.64k
      break;
2224
1.64k
#endif
2225
#ifdef AARCH64MAGIC
2226
662
    case AARCH64MAGIC:
2227
662
      arch = bfd_arch_aarch64;
2228
662
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
662
      break;
2230
0
#endif
2231
#ifdef LOONGARCH64MAGIC
2232
418
    case LOONGARCH64MAGIC:
2233
418
      arch = bfd_arch_loongarch;
2234
418
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
418
      break;
2236
0
#endif
2237
#ifdef Z80MAGIC
2238
139
    case Z80MAGIC:
2239
139
      arch = bfd_arch_z80;
2240
139
      switch (internal_f->f_flags & F_MACHMASK)
2241
139
  {
2242
10
  case bfd_mach_z80strict << 12:
2243
25
  case bfd_mach_z80 << 12:
2244
48
  case bfd_mach_z80n << 12:
2245
61
  case bfd_mach_z80full << 12:
2246
63
  case bfd_mach_r800 << 12:
2247
91
  case bfd_mach_gbz80 << 12:
2248
123
  case bfd_mach_z180 << 12:
2249
135
  case bfd_mach_ez80_z80 << 12:
2250
138
  case bfd_mach_ez80_adl << 12:
2251
138
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
138
    break;
2253
1
  default:
2254
1
    return false;
2255
139
  }
2256
138
      break;
2257
138
#endif
2258
#ifdef Z8KMAGIC
2259
149
    case Z8KMAGIC:
2260
149
      arch = bfd_arch_z8k;
2261
149
      switch (internal_f->f_flags & F_MACHMASK)
2262
149
  {
2263
74
  case F_Z8001:
2264
74
    machine = bfd_mach_z8001;
2265
74
    break;
2266
72
  case F_Z8002:
2267
72
    machine = bfd_mach_z8002;
2268
72
    break;
2269
3
  default:
2270
3
    return false;
2271
149
  }
2272
146
      break;
2273
146
#endif
2274
2275
#ifdef RS6000COFF_C
2276
#ifdef XCOFF64
2277
9
    case U64_TOCMAGIC:
2278
367
    case U803XTOCMAGIC:
2279
#else
2280
34
    case U802ROMAGIC:
2281
62
    case U802WRMAGIC:
2282
418
    case U802TOCMAGIC:
2283
#endif
2284
418
      {
2285
418
  int cputype;
2286
2287
785
  if (xcoff_data (abfd)->cputype != -1)
2288
202
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
583
  else
2290
583
    {
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
583
      if (obj_raw_syment_count (abfd) == 0)
2296
224
        cputype = 0;
2297
359
      else
2298
359
        {
2299
359
    bfd_byte *buf;
2300
359
    struct internal_syment sym;
2301
359
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
359
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
17
      return false;
2305
342
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
342
    if (buf == NULL)
2307
40
      return false;
2308
302
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
302
    if (sym.n_sclass == C_FILE)
2310
2
      cputype = sym.n_type & 0xff;
2311
300
    else
2312
300
      cputype = 0;
2313
302
    free (buf);
2314
302
        }
2315
583
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
728
  switch (cputype)
2319
728
    {
2320
91
    default:
2321
704
    case 0:
2322
704
      arch = bfd_xcoff_architecture (abfd);
2323
704
      machine = bfd_xcoff_machine (abfd);
2324
704
      break;
2325
2326
10
    case 1:
2327
10
      arch = bfd_arch_powerpc;
2328
10
      machine = bfd_mach_ppc_601;
2329
10
      break;
2330
7
    case 2: /* 64 bit PowerPC */
2331
7
      arch = bfd_arch_powerpc;
2332
7
      machine = bfd_mach_ppc_620;
2333
7
      break;
2334
4
    case 3:
2335
4
      arch = bfd_arch_powerpc;
2336
4
      machine = bfd_mach_ppc;
2337
4
      break;
2338
3
    case 4:
2339
3
      arch = bfd_arch_rs6000;
2340
3
      machine = bfd_mach_rs6k;
2341
3
      break;
2342
728
    }
2343
728
      }
2344
728
      break;
2345
728
#endif
2346
2347
#ifdef SH_ARCH_MAGIC_BIG
2348
1.17k
    case SH_ARCH_MAGIC_BIG:
2349
1.19k
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
785
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
785
      arch = bfd_arch_sh;
2354
785
      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
182
    case TIC30MAGIC:
2374
182
      arch = bfd_arch_tic30;
2375
182
      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
118
    case TICOFF0MAGIC:
2382
118
      arch = TICOFF_TARGET_ARCH;
2383
118
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
118
      break;
2385
0
#endif
2386
0
#endif
2387
2388
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
1
    case TICOFF1MAGIC:
2392
19
    case TICOFF2MAGIC:
2393
19
      switch (internal_f->f_target_id)
2394
19
  {
2395
0
#ifdef TI_TARGET_ID
2396
19
  case TI_TARGET_ID:
2397
19
    arch = TICOFF_TARGET_ARCH;
2398
19
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
19
    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
19
  }
2408
19
      break;
2409
19
#endif
2410
2411
#ifdef MCOREMAGIC
2412
633
    case MCOREMAGIC:
2413
633
      arch = bfd_arch_mcore;
2414
633
      break;
2415
0
#endif
2416
2417
88
    default:      /* Unreadable input file type.  */
2418
88
      arch = bfd_arch_obscure;
2419
88
      break;
2420
11.9k
    }
2421
2422
11.8k
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
11.8k
  return true;
2424
11.9k
}
pei-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
447
{
2163
447
  unsigned long machine;
2164
447
  enum bfd_architecture arch;
2165
447
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
447
  machine = 0;
2169
447
  switch (internal_f->f_magic)
2170
447
    {
2171
0
#ifdef I386MAGIC
2172
210
    case I386MAGIC:
2173
271
    case I386PTXMAGIC:
2174
307
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
419
    case LYNXCOFFMAGIC:
2176
438
    case I386_APPLE_MAGIC:
2177
441
    case I386_FREEBSD_MAGIC:
2178
444
    case I386_LINUX_MAGIC:
2179
447
    case I386_NETBSD_MAGIC:
2180
447
      arch = bfd_arch_i386;
2181
447
      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
447
    }
2421
2422
447
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
447
  return true;
2424
447
}
pe-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
812
{
2163
812
  unsigned long machine;
2164
812
  enum bfd_architecture arch;
2165
812
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
812
  machine = 0;
2169
812
  switch (internal_f->f_magic)
2170
812
    {
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
58
    case AMD64MAGIC:
2185
787
    case AMD64_APPLE_MAGIC:
2186
797
    case AMD64_FREEBSD_MAGIC:
2187
801
    case AMD64_LINUX_MAGIC:
2188
812
    case AMD64_NETBSD_MAGIC:
2189
812
      arch = bfd_arch_i386;
2190
812
      machine = bfd_mach_x86_64;
2191
812
      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
812
    }
2421
2422
812
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
812
  return true;
2424
812
}
pei-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
570
{
2163
570
  unsigned long machine;
2164
570
  enum bfd_architecture arch;
2165
570
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
570
  machine = 0;
2169
570
  switch (internal_f->f_magic)
2170
570
    {
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
539
    case AMD64MAGIC:
2185
547
    case AMD64_APPLE_MAGIC:
2186
547
    case AMD64_FREEBSD_MAGIC:
2187
570
    case AMD64_LINUX_MAGIC:
2188
570
    case AMD64_NETBSD_MAGIC:
2189
570
      arch = bfd_arch_i386;
2190
570
      machine = bfd_mach_x86_64;
2191
570
      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
570
    }
2421
2422
570
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
570
  return true;
2424
570
}
coff-x86_64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
589
{
2163
589
  unsigned long machine;
2164
589
  enum bfd_architecture arch;
2165
589
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
589
  machine = 0;
2169
589
  switch (internal_f->f_magic)
2170
589
    {
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
24
    case AMD64MAGIC:
2185
569
    case AMD64_APPLE_MAGIC:
2186
576
    case AMD64_FREEBSD_MAGIC:
2187
579
    case AMD64_LINUX_MAGIC:
2188
589
    case AMD64_NETBSD_MAGIC:
2189
589
      arch = bfd_arch_i386;
2190
589
      machine = bfd_mach_x86_64;
2191
589
      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
589
    }
2421
2422
589
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
589
  return true;
2424
589
}
coff64-rs6000.c:coff_set_arch_mach_hook
Line
Count
Source
2162
367
{
2163
367
  unsigned long machine;
2164
367
  enum bfd_architecture arch;
2165
367
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
367
  machine = 0;
2169
367
  switch (internal_f->f_magic)
2170
367
    {
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
9
    case U64_TOCMAGIC:
2278
367
    case U803XTOCMAGIC:
2279
#else
2280
    case U802ROMAGIC:
2281
    case U802WRMAGIC:
2282
    case U802TOCMAGIC:
2283
#endif
2284
367
      {
2285
367
  int cputype;
2286
2287
367
  if (xcoff_data (abfd)->cputype != -1)
2288
105
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
262
  else
2290
262
    {
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
262
      if (obj_raw_syment_count (abfd) == 0)
2296
138
        cputype = 0;
2297
124
      else
2298
124
        {
2299
124
    bfd_byte *buf;
2300
124
    struct internal_syment sym;
2301
124
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
124
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
17
      return false;
2305
107
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
107
    if (buf == NULL)
2307
11
      return false;
2308
96
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
96
    if (sym.n_sclass == C_FILE)
2310
1
      cputype = sym.n_type & 0xff;
2311
95
    else
2312
95
      cputype = 0;
2313
96
    free (buf);
2314
96
        }
2315
262
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
339
  switch (cputype)
2319
339
    {
2320
33
    default:
2321
327
    case 0:
2322
327
      arch = bfd_xcoff_architecture (abfd);
2323
327
      machine = bfd_xcoff_machine (abfd);
2324
327
      break;
2325
2326
6
    case 1:
2327
6
      arch = bfd_arch_powerpc;
2328
6
      machine = bfd_mach_ppc_601;
2329
6
      break;
2330
3
    case 2: /* 64 bit PowerPC */
2331
3
      arch = bfd_arch_powerpc;
2332
3
      machine = bfd_mach_ppc_620;
2333
3
      break;
2334
1
    case 3:
2335
1
      arch = bfd_arch_powerpc;
2336
1
      machine = bfd_mach_ppc;
2337
1
      break;
2338
2
    case 4:
2339
2
      arch = bfd_arch_rs6000;
2340
2
      machine = bfd_mach_rs6k;
2341
2
      break;
2342
339
    }
2343
339
      }
2344
339
      break;
2345
339
#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
339
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
367
    }
2421
2422
339
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
339
  return true;
2424
367
}
pe-aarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
229
{
2163
229
  unsigned long machine;
2164
229
  enum bfd_architecture arch;
2165
229
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
229
  machine = 0;
2169
229
  switch (internal_f->f_magic)
2170
229
    {
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
229
    case AARCH64MAGIC:
2227
229
      arch = bfd_arch_aarch64;
2228
229
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
229
      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
229
    }
2421
2422
229
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
229
  return true;
2424
229
}
pei-aarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
433
{
2163
433
  unsigned long machine;
2164
433
  enum bfd_architecture arch;
2165
433
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
433
  machine = 0;
2169
433
  switch (internal_f->f_magic)
2170
433
    {
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
433
    case AARCH64MAGIC:
2227
433
      arch = bfd_arch_aarch64;
2228
433
      machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK;
2229
433
      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
433
    }
2421
2422
433
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
433
  return true;
2424
433
}
pei-ia64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
366
{
2163
366
  unsigned long machine;
2164
366
  enum bfd_architecture arch;
2165
366
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
366
  machine = 0;
2169
366
  switch (internal_f->f_magic)
2170
366
    {
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
366
    case IA64MAGIC:
2195
366
      arch = bfd_arch_ia64;
2196
366
      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
366
    }
2421
2422
366
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
366
  return true;
2424
366
}
pei-loongarch64.c:coff_set_arch_mach_hook
Line
Count
Source
2162
418
{
2163
418
  unsigned long machine;
2164
418
  enum bfd_architecture arch;
2165
418
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
418
  machine = 0;
2169
418
  switch (internal_f->f_magic)
2170
418
    {
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
418
    case LOONGARCH64MAGIC:
2233
418
      arch = bfd_arch_loongarch;
2234
418
      machine = internal_f->f_flags & F_LOONGARCH64_ARCHITECTURE_MASK;
2235
418
      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
418
    }
2421
2422
418
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
418
  return true;
2424
418
}
cf-i386lynx.c:coff_set_arch_mach_hook
Line
Count
Source
2162
796
{
2163
796
  unsigned long machine;
2164
796
  enum bfd_architecture arch;
2165
796
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
796
  machine = 0;
2169
796
  switch (internal_f->f_magic)
2170
796
    {
2171
0
#ifdef I386MAGIC
2172
601
    case I386MAGIC:
2173
604
    case I386PTXMAGIC:
2174
611
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
743
    case LYNXCOFFMAGIC:
2176
763
    case I386_APPLE_MAGIC:
2177
764
    case I386_FREEBSD_MAGIC:
2178
765
    case I386_LINUX_MAGIC:
2179
796
    case I386_NETBSD_MAGIC:
2180
796
      arch = bfd_arch_i386;
2181
796
      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
796
    }
2421
2422
796
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
796
  return true;
2424
796
}
coff-go32.c:coff_set_arch_mach_hook
Line
Count
Source
2162
612
{
2163
612
  unsigned long machine;
2164
612
  enum bfd_architecture arch;
2165
612
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
612
  machine = 0;
2169
612
  switch (internal_f->f_magic)
2170
612
    {
2171
0
#ifdef I386MAGIC
2172
438
    case I386MAGIC:
2173
440
    case I386PTXMAGIC:
2174
446
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
576
    case LYNXCOFFMAGIC:
2176
594
    case I386_APPLE_MAGIC:
2177
595
    case I386_FREEBSD_MAGIC:
2178
596
    case I386_LINUX_MAGIC:
2179
612
    case I386_NETBSD_MAGIC:
2180
612
      arch = bfd_arch_i386;
2181
612
      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
612
    }
2421
2422
612
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
612
  return true;
2424
612
}
coff-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
612
{
2163
612
  unsigned long machine;
2164
612
  enum bfd_architecture arch;
2165
612
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
612
  machine = 0;
2169
612
  switch (internal_f->f_magic)
2170
612
    {
2171
0
#ifdef I386MAGIC
2172
438
    case I386MAGIC:
2173
440
    case I386PTXMAGIC:
2174
446
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
576
    case LYNXCOFFMAGIC:
2176
594
    case I386_APPLE_MAGIC:
2177
595
    case I386_FREEBSD_MAGIC:
2178
596
    case I386_LINUX_MAGIC:
2179
612
    case I386_NETBSD_MAGIC:
2180
612
      arch = bfd_arch_i386;
2181
612
      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
612
    }
2421
2422
612
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
612
  return true;
2424
612
}
coff-rs6000.c:coff_set_arch_mach_hook
Line
Count
Source
2162
418
{
2163
418
  unsigned long machine;
2164
418
  enum bfd_architecture arch;
2165
418
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
418
  machine = 0;
2169
418
  switch (internal_f->f_magic)
2170
418
    {
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
34
    case U802ROMAGIC:
2281
62
    case U802WRMAGIC:
2282
418
    case U802TOCMAGIC:
2283
418
#endif
2284
418
      {
2285
418
  int cputype;
2286
2287
418
  if (xcoff_data (abfd)->cputype != -1)
2288
97
    cputype = xcoff_data (abfd)->cputype & 0xff;
2289
321
  else
2290
321
    {
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
321
      if (obj_raw_syment_count (abfd) == 0)
2296
86
        cputype = 0;
2297
235
      else
2298
235
        {
2299
235
    bfd_byte *buf;
2300
235
    struct internal_syment sym;
2301
235
    bfd_size_type amt = bfd_coff_symesz (abfd);
2302
2303
235
    if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
2304
0
      return false;
2305
235
    buf = _bfd_malloc_and_read (abfd, amt, amt);
2306
235
    if (buf == NULL)
2307
29
      return false;
2308
206
    bfd_coff_swap_sym_in (abfd, buf, & sym);
2309
206
    if (sym.n_sclass == C_FILE)
2310
1
      cputype = sym.n_type & 0xff;
2311
205
    else
2312
205
      cputype = 0;
2313
206
    free (buf);
2314
206
        }
2315
321
    }
2316
2317
  /* FIXME: We don't handle all cases here.  */
2318
389
  switch (cputype)
2319
389
    {
2320
58
    default:
2321
377
    case 0:
2322
377
      arch = bfd_xcoff_architecture (abfd);
2323
377
      machine = bfd_xcoff_machine (abfd);
2324
377
      break;
2325
2326
4
    case 1:
2327
4
      arch = bfd_arch_powerpc;
2328
4
      machine = bfd_mach_ppc_601;
2329
4
      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
3
    case 3:
2335
3
      arch = bfd_arch_powerpc;
2336
3
      machine = bfd_mach_ppc;
2337
3
      break;
2338
1
    case 4:
2339
1
      arch = bfd_arch_rs6000;
2340
1
      machine = bfd_mach_rs6k;
2341
1
      break;
2342
389
    }
2343
389
      }
2344
389
      break;
2345
389
#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
389
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
418
    }
2421
2422
389
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
389
  return true;
2424
418
}
coff-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
457
{
2163
457
  unsigned long machine;
2164
457
  enum bfd_architecture arch;
2165
457
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
457
  machine = 0;
2169
457
  switch (internal_f->f_magic)
2170
457
    {
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
443
    case SH_ARCH_MAGIC_BIG:
2349
450
    case SH_ARCH_MAGIC_LITTLE:
2350
#ifdef COFF_WITH_PE
2351
    case SH_ARCH_MAGIC_WINCE:
2352
#endif
2353
450
      arch = bfd_arch_sh;
2354
450
      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
7
    default:      /* Unreadable input file type.  */
2418
7
      arch = bfd_arch_obscure;
2419
7
      break;
2420
457
    }
2421
2422
457
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
457
  return true;
2424
457
}
coff-stgo32.c:coff_set_arch_mach_hook
Line
Count
Source
2162
196
{
2163
196
  unsigned long machine;
2164
196
  enum bfd_architecture arch;
2165
196
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
196
  machine = 0;
2169
196
  switch (internal_f->f_magic)
2170
196
    {
2171
0
#ifdef I386MAGIC
2172
173
    case I386MAGIC:
2173
174
    case I386PTXMAGIC:
2174
175
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
177
    case LYNXCOFFMAGIC:
2176
179
    case I386_APPLE_MAGIC:
2177
179
    case I386_FREEBSD_MAGIC:
2178
179
    case I386_LINUX_MAGIC:
2179
196
    case I386_NETBSD_MAGIC:
2180
196
      arch = bfd_arch_i386;
2181
196
      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
196
    }
2421
2422
196
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
196
  return true;
2424
196
}
coff-tic30.c:coff_set_arch_mach_hook
Line
Count
Source
2162
182
{
2163
182
  unsigned long machine;
2164
182
  enum bfd_architecture arch;
2165
182
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
182
  machine = 0;
2169
182
  switch (internal_f->f_magic)
2170
182
    {
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
182
    case TIC30MAGIC:
2374
182
      arch = bfd_arch_tic30;
2375
182
      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
182
    }
2421
2422
182
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
182
  return true;
2424
182
}
Unexecuted instantiation: coff-tic4x.c:coff_set_arch_mach_hook
coff-tic54x.c:coff_set_arch_mach_hook
Line
Count
Source
2162
137
{
2163
137
  unsigned long machine;
2164
137
  enum bfd_architecture arch;
2165
137
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
137
  machine = 0;
2169
137
  switch (internal_f->f_magic)
2170
137
    {
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
118
    case TICOFF0MAGIC:
2382
118
      arch = TICOFF_TARGET_ARCH;
2383
118
      machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2384
118
      break;
2385
0
#endif
2386
0
#endif
2387
2388
0
#ifdef TICOFF1MAGIC
2389
      /* This TI COFF section should be used by all new TI COFF v1/2 targets.  */
2390
      /* TI COFF1 and COFF2 use the target_id field to specify which arch.  */
2391
1
    case TICOFF1MAGIC:
2392
19
    case TICOFF2MAGIC:
2393
19
      switch (internal_f->f_target_id)
2394
19
  {
2395
0
#ifdef TI_TARGET_ID
2396
19
  case TI_TARGET_ID:
2397
19
    arch = TICOFF_TARGET_ARCH;
2398
19
    machine = TICOFF_TARGET_MACHINE_GET (internal_f->f_flags);
2399
19
    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
19
  }
2408
19
      break;
2409
19
#endif
2410
2411
#ifdef MCOREMAGIC
2412
    case MCOREMAGIC:
2413
      arch = bfd_arch_mcore;
2414
      break;
2415
#endif
2416
2417
19
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
137
    }
2421
2422
137
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
137
  return true;
2424
137
}
coff-z80.c:coff_set_arch_mach_hook
Line
Count
Source
2162
139
{
2163
139
  unsigned long machine;
2164
139
  enum bfd_architecture arch;
2165
139
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
139
  machine = 0;
2169
139
  switch (internal_f->f_magic)
2170
139
    {
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
139
    case Z80MAGIC:
2239
139
      arch = bfd_arch_z80;
2240
139
      switch (internal_f->f_flags & F_MACHMASK)
2241
139
  {
2242
10
  case bfd_mach_z80strict << 12:
2243
25
  case bfd_mach_z80 << 12:
2244
48
  case bfd_mach_z80n << 12:
2245
61
  case bfd_mach_z80full << 12:
2246
63
  case bfd_mach_r800 << 12:
2247
91
  case bfd_mach_gbz80 << 12:
2248
123
  case bfd_mach_z180 << 12:
2249
135
  case bfd_mach_ez80_z80 << 12:
2250
138
  case bfd_mach_ez80_adl << 12:
2251
138
    machine = ((unsigned)internal_f->f_flags & F_MACHMASK) >> 12;
2252
138
    break;
2253
1
  default:
2254
1
    return false;
2255
139
  }
2256
138
      break;
2257
138
#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
138
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
139
    }
2421
2422
138
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
138
  return true;
2424
139
}
coff-z8k.c:coff_set_arch_mach_hook
Line
Count
Source
2162
149
{
2163
149
  unsigned long machine;
2164
149
  enum bfd_architecture arch;
2165
149
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
149
  machine = 0;
2169
149
  switch (internal_f->f_magic)
2170
149
    {
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
149
    case Z8KMAGIC:
2260
149
      arch = bfd_arch_z8k;
2261
149
      switch (internal_f->f_flags & F_MACHMASK)
2262
149
  {
2263
74
  case F_Z8001:
2264
74
    machine = bfd_mach_z8001;
2265
74
    break;
2266
72
  case F_Z8002:
2267
72
    machine = bfd_mach_z8002;
2268
72
    break;
2269
3
  default:
2270
3
    return false;
2271
149
  }
2272
146
      break;
2273
146
#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
146
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
149
    }
2421
2422
146
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
146
  return true;
2424
149
}
pe-arm-wince.c:coff_set_arch_mach_hook
Line
Count
Source
2162
424
{
2163
424
  unsigned long machine;
2164
424
  enum bfd_architecture arch;
2165
424
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
424
  machine = 0;
2169
424
  switch (internal_f->f_magic)
2170
424
    {
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
343
    case ARMMAGIC:
2200
384
    case ARMPEMAGIC:
2201
422
    case THUMBPEMAGIC:
2202
422
      arch = bfd_arch_arm;
2203
422
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
422
      if (machine == bfd_mach_arm_unknown)
2205
422
  {
2206
422
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
422
      {
2208
47
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
44
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
24
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
163
      default:
2212
231
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
15
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
29
      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
32
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
422
      }
2222
422
  }
2223
422
      break;
2224
422
#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
422
    default:      /* Unreadable input file type.  */
2418
2
      arch = bfd_arch_obscure;
2419
2
      break;
2420
424
    }
2421
2422
424
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
424
  return true;
2424
424
}
pe-arm.c:coff_set_arch_mach_hook
Line
Count
Source
2162
424
{
2163
424
  unsigned long machine;
2164
424
  enum bfd_architecture arch;
2165
424
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
424
  machine = 0;
2169
424
  switch (internal_f->f_magic)
2170
424
    {
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
343
    case ARMMAGIC:
2200
384
    case ARMPEMAGIC:
2201
422
    case THUMBPEMAGIC:
2202
422
      arch = bfd_arch_arm;
2203
422
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
422
      if (machine == bfd_mach_arm_unknown)
2205
422
  {
2206
422
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
422
      {
2208
47
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
44
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
24
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
163
      default:
2212
231
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
15
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
29
      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
32
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
422
      }
2222
422
  }
2223
422
      break;
2224
422
#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
422
    default:      /* Unreadable input file type.  */
2418
2
      arch = bfd_arch_obscure;
2419
2
      break;
2420
424
    }
2421
2422
424
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
424
  return true;
2424
424
}
pe-i386.c:coff_set_arch_mach_hook
Line
Count
Source
2162
829
{
2163
829
  unsigned long machine;
2164
829
  enum bfd_architecture arch;
2165
829
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
829
  machine = 0;
2169
829
  switch (internal_f->f_magic)
2170
829
    {
2171
0
#ifdef I386MAGIC
2172
605
    case I386MAGIC:
2173
636
    case I386PTXMAGIC:
2174
643
    case I386AIXMAGIC:   /* Danbury PS/2 AIX C Compiler.  */
2175
776
    case LYNXCOFFMAGIC:
2176
796
    case I386_APPLE_MAGIC:
2177
797
    case I386_FREEBSD_MAGIC:
2178
798
    case I386_LINUX_MAGIC:
2179
829
    case I386_NETBSD_MAGIC:
2180
829
      arch = bfd_arch_i386;
2181
829
      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
829
    }
2421
2422
829
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
829
  return true;
2424
829
}
pe-mcore.c:coff_set_arch_mach_hook
Line
Count
Source
2162
276
{
2163
276
  unsigned long machine;
2164
276
  enum bfd_architecture arch;
2165
276
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
276
  machine = 0;
2169
276
  switch (internal_f->f_magic)
2170
276
    {
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
276
    case MCOREMAGIC:
2413
276
      arch = bfd_arch_mcore;
2414
276
      break;
2415
0
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
276
    }
2421
2422
276
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
276
  return true;
2424
276
}
pe-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
467
{
2163
467
  unsigned long machine;
2164
467
  enum bfd_architecture arch;
2165
467
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
467
  machine = 0;
2169
467
  switch (internal_f->f_magic)
2170
467
    {
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
454
    case SH_ARCH_MAGIC_BIG:
2349
461
    case SH_ARCH_MAGIC_LITTLE:
2350
461
#ifdef COFF_WITH_PE
2351
467
    case SH_ARCH_MAGIC_WINCE:
2352
467
#endif
2353
467
      arch = bfd_arch_sh;
2354
467
      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
467
    }
2421
2422
467
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
467
  return true;
2424
467
}
pei-arm-wince.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
#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
130
    case ARMMAGIC:
2200
329
    case ARMPEMAGIC:
2201
354
    case THUMBPEMAGIC:
2202
354
      arch = bfd_arch_arm;
2203
354
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
354
      if (machine == bfd_mach_arm_unknown)
2205
354
  {
2206
354
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
354
      {
2208
68
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
11
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
18
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
100
      default:
2212
102
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
58
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
53
      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
44
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
354
      }
2222
354
  }
2223
354
      break;
2224
354
#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
354
    default:      /* Unreadable input file type.  */
2418
34
      arch = bfd_arch_obscure;
2419
34
      break;
2420
388
    }
2421
2422
388
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
388
  return true;
2424
388
}
pei-arm.c:coff_set_arch_mach_hook
Line
Count
Source
2162
494
{
2163
494
  unsigned long machine;
2164
494
  enum bfd_architecture arch;
2165
494
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
494
  machine = 0;
2169
494
  switch (internal_f->f_magic)
2170
494
    {
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
181
    case ARMMAGIC:
2200
426
    case ARMPEMAGIC:
2201
451
    case THUMBPEMAGIC:
2202
451
      arch = bfd_arch_arm;
2203
451
      machine = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
2204
451
      if (machine == bfd_mach_arm_unknown)
2205
451
  {
2206
451
    switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK)
2207
451
      {
2208
99
      case F_ARM_2:  machine = bfd_mach_arm_2;  break;
2209
23
      case F_ARM_2a: machine = bfd_mach_arm_2a; break;
2210
17
      case F_ARM_3:  machine = bfd_mach_arm_3;  break;
2211
120
      default:
2212
122
      case F_ARM_3M: machine = bfd_mach_arm_3M; break;
2213
70
      case F_ARM_4:  machine = bfd_mach_arm_4;  break;
2214
62
      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
58
      case F_ARM_5:  machine = bfd_mach_arm_XScale;  break;
2221
451
      }
2222
451
  }
2223
451
      break;
2224
451
#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
451
    default:      /* Unreadable input file type.  */
2418
43
      arch = bfd_arch_obscure;
2419
43
      break;
2420
494
    }
2421
2422
494
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
494
  return true;
2424
494
}
pei-mcore.c:coff_set_arch_mach_hook
Line
Count
Source
2162
357
{
2163
357
  unsigned long machine;
2164
357
  enum bfd_architecture arch;
2165
357
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
357
  machine = 0;
2169
357
  switch (internal_f->f_magic)
2170
357
    {
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
357
    case MCOREMAGIC:
2413
357
      arch = bfd_arch_mcore;
2414
357
      break;
2415
0
#endif
2416
2417
0
    default:      /* Unreadable input file type.  */
2418
0
      arch = bfd_arch_obscure;
2419
0
      break;
2420
357
    }
2421
2422
357
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
357
  return true;
2424
357
}
pei-sh.c:coff_set_arch_mach_hook
Line
Count
Source
2162
318
{
2163
318
  unsigned long machine;
2164
318
  enum bfd_architecture arch;
2165
318
  struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
2166
2167
  /* Zero selects the default machine for an arch.  */
2168
318
  machine = 0;
2169
318
  switch (internal_f->f_magic)
2170
318
    {
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
281
    case SH_ARCH_MAGIC_BIG:
2349
284
    case SH_ARCH_MAGIC_LITTLE:
2350
284
#ifdef COFF_WITH_PE
2351
318
    case SH_ARCH_MAGIC_WINCE:
2352
318
#endif
2353
318
      arch = bfd_arch_sh;
2354
318
      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
318
    }
2421
2422
318
  bfd_default_set_arch_mach (abfd, arch, machine);
2423
318
  return true;
2424
318
}
2425
2426
static bool
2427
symname_in_debug_hook (bfd *abfd ATTRIBUTE_UNUSED,
2428
           struct internal_syment *sym ATTRIBUTE_UNUSED)
2429
0
{
2430
#ifdef SYMNAME_IN_DEBUG
2431
0
  return SYMNAME_IN_DEBUG (sym) != 0;
2432
#else
2433
  return false;
2434
#endif
2435
0
}
Unexecuted instantiation: pei-i386.c:symname_in_debug_hook
Unexecuted instantiation: pe-x86_64.c:symname_in_debug_hook
Unexecuted instantiation: pei-x86_64.c:symname_in_debug_hook
Unexecuted instantiation: coff-x86_64.c:symname_in_debug_hook
Unexecuted instantiation: coff64-rs6000.c:symname_in_debug_hook
Unexecuted instantiation: pe-aarch64.c:symname_in_debug_hook
Unexecuted instantiation: pei-aarch64.c:symname_in_debug_hook
Unexecuted instantiation: pei-ia64.c:symname_in_debug_hook
Unexecuted instantiation: pei-loongarch64.c:symname_in_debug_hook
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
Unexecuted instantiation: coff-rs6000.c:symname_in_debug_hook
Unexecuted instantiation: coff-sh.c:symname_in_debug_hook
Unexecuted instantiation: coff-stgo32.c:symname_in_debug_hook
Unexecuted instantiation: coff-tic30.c:symname_in_debug_hook
Unexecuted instantiation: coff-tic4x.c:symname_in_debug_hook
Unexecuted instantiation: coff-tic54x.c:symname_in_debug_hook
Unexecuted instantiation: coff-z80.c:symname_in_debug_hook
Unexecuted instantiation: coff-z8k.c:symname_in_debug_hook
Unexecuted instantiation: pe-arm-wince.c:symname_in_debug_hook
Unexecuted instantiation: pe-arm.c:symname_in_debug_hook
Unexecuted instantiation: pe-i386.c:symname_in_debug_hook
Unexecuted instantiation: pe-mcore.c:symname_in_debug_hook
Unexecuted instantiation: pe-sh.c:symname_in_debug_hook
Unexecuted instantiation: pei-arm-wince.c:symname_in_debug_hook
Unexecuted instantiation: pei-arm.c:symname_in_debug_hook
Unexecuted instantiation: pei-mcore.c:symname_in_debug_hook
Unexecuted instantiation: pei-sh.c:symname_in_debug_hook
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
0
{
2452
0
  BFD_ASSERT (symbol->is_sym);
2453
0
  int n_sclass = symbol->u.syment.n_sclass;
2454
2455
0
  if (CSECT_SYM_P (n_sclass)
2456
0
      && indaux + 1 == symbol->u.syment.n_numaux)
2457
0
    {
2458
0
      BFD_ASSERT (! aux->is_sym);
2459
0
      if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD
2460
0
    && aux->u.auxent.x_csect.x_scnlen.u64 < obj_raw_syment_count (abfd))
2461
0
  {
2462
0
    aux->u.auxent.x_csect.x_scnlen.p =
2463
0
      table_base + aux->u.auxent.x_csect.x_scnlen.u64;
2464
0
    aux->fix_scnlen = 1;
2465
0
  }
2466
2467
      /* Return TRUE to indicate that the caller should not do any
2468
   further work on this auxent.  */
2469
0
      return true;
2470
0
    }
2471
2472
  /* Return FALSE to indicate that this auxent should be handled by
2473
     the caller.  */
2474
0
  return false;
2475
0
}
Unexecuted instantiation: coff64-rs6000.c:coff_pointerize_aux_hook
Unexecuted instantiation: coff-rs6000.c:coff_pointerize_aux_hook
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
0
{
4435
0
  size_t amt;
4436
4437
0
  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
0
  if (bfd_seek (abfd, where, SEEK_SET) != 0)
4443
0
    return NULL;
4444
0
  return _bfd_malloc_and_read (abfd, amt, amt);
4445
0
}
Unexecuted instantiation: pei-i386.c:buy_and_read
Unexecuted instantiation: pe-x86_64.c:buy_and_read
Unexecuted instantiation: pei-x86_64.c:buy_and_read
Unexecuted instantiation: coff-x86_64.c:buy_and_read
Unexecuted instantiation: coff64-rs6000.c:buy_and_read
Unexecuted instantiation: pe-aarch64.c:buy_and_read
Unexecuted instantiation: pei-aarch64.c:buy_and_read
Unexecuted instantiation: pei-ia64.c:buy_and_read
Unexecuted instantiation: pei-loongarch64.c:buy_and_read
Unexecuted instantiation: cf-i386lynx.c:buy_and_read
Unexecuted instantiation: coff-go32.c:buy_and_read
Unexecuted instantiation: coff-i386.c:buy_and_read
Unexecuted instantiation: coff-rs6000.c:buy_and_read
Unexecuted instantiation: coff-sh.c:buy_and_read
Unexecuted instantiation: coff-stgo32.c:buy_and_read
Unexecuted instantiation: coff-tic30.c:buy_and_read
Unexecuted instantiation: coff-tic4x.c:buy_and_read
Unexecuted instantiation: coff-tic54x.c:buy_and_read
Unexecuted instantiation: coff-z80.c:buy_and_read
Unexecuted instantiation: coff-z8k.c:buy_and_read
Unexecuted instantiation: pe-arm-wince.c:buy_and_read
Unexecuted instantiation: pe-arm.c:buy_and_read
Unexecuted instantiation: pe-i386.c:buy_and_read
Unexecuted instantiation: pe-mcore.c:buy_and_read
Unexecuted instantiation: pe-sh.c:buy_and_read
Unexecuted instantiation: pei-arm-wince.c:buy_and_read
Unexecuted instantiation: pei-arm.c:buy_and_read
Unexecuted instantiation: pei-mcore.c:buy_and_read
Unexecuted instantiation: pei-sh.c:buy_and_read
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
0
{
4473
0
  const alent *al1 = *(const alent **) arg1;
4474
0
  const alent *al2 = *(const alent **) arg2;
4475
0
  const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym);
4476
0
  const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym);
4477
4478
0
  if (s1 == NULL || s2 == NULL)
4479
0
    return 0;
4480
0
  if (s1->symbol.value < s2->symbol.value)
4481
0
    return -1;
4482
0
  else if (s1->symbol.value > s2->symbol.value)
4483
0
    return 1;
4484
4485
0
  return 0;
4486
0
}
Unexecuted instantiation: pei-i386.c:coff_sort_func_alent
Unexecuted instantiation: pe-x86_64.c:coff_sort_func_alent
Unexecuted instantiation: pei-x86_64.c:coff_sort_func_alent
Unexecuted instantiation: coff-x86_64.c:coff_sort_func_alent
Unexecuted instantiation: coff64-rs6000.c:coff_sort_func_alent
Unexecuted instantiation: pe-aarch64.c:coff_sort_func_alent
Unexecuted instantiation: pei-aarch64.c:coff_sort_func_alent
Unexecuted instantiation: pei-ia64.c:coff_sort_func_alent
Unexecuted instantiation: pei-loongarch64.c:coff_sort_func_alent
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
Unexecuted instantiation: coff-rs6000.c:coff_sort_func_alent
Unexecuted instantiation: coff-sh.c:coff_sort_func_alent
Unexecuted instantiation: coff-stgo32.c:coff_sort_func_alent
Unexecuted instantiation: coff-tic30.c:coff_sort_func_alent
Unexecuted instantiation: coff-tic4x.c:coff_sort_func_alent
Unexecuted instantiation: coff-tic54x.c:coff_sort_func_alent
Unexecuted instantiation: coff-z80.c:coff_sort_func_alent
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
Unexecuted instantiation: pe-i386.c:coff_sort_func_alent
Unexecuted instantiation: pe-mcore.c:coff_sort_func_alent
Unexecuted instantiation: pe-sh.c:coff_sort_func_alent
Unexecuted instantiation: pei-arm-wince.c:coff_sort_func_alent
Unexecuted instantiation: pei-arm.c:coff_sort_func_alent
Unexecuted instantiation: pei-mcore.c:coff_sort_func_alent
Unexecuted instantiation: pei-sh.c:coff_sort_func_alent
4487
4488
static bool
4489
coff_slurp_line_table (bfd *abfd, asection *asect)
4490
0
{
4491
0
  LINENO *native_lineno;
4492
0
  alent *lineno_cache;
4493
0
  unsigned int counter;
4494
0
  alent *cache_ptr;
4495
0
  bfd_vma prev_offset = 0;
4496
0
  bool ordered = true;
4497
0
  unsigned int nbr_func;
4498
0
  LINENO *src;
4499
0
  bool have_func;
4500
0
  bool ret = true;
4501
0
  size_t amt;
4502
4503
0
  if (asect->lineno_count == 0)
4504
0
    return true;
4505
4506
0
  BFD_ASSERT (asect->lineno == NULL);
4507
4508
0
  native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos,
4509
0
             asect->lineno_count,
4510
0
             bfd_coff_linesz (abfd));
4511
0
  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
0
  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
0
  lineno_cache = (alent *) bfd_alloc (abfd, amt);
4525
0
  if (lineno_cache == NULL)
4526
0
    {
4527
0
      free (native_lineno);
4528
0
      return false;
4529
0
    }
4530
4531
0
  cache_ptr = lineno_cache;
4532
0
  asect->lineno = lineno_cache;
4533
0
  src = native_lineno;
4534
0
  nbr_func = 0;
4535
0
  have_func = false;
4536
4537
0
  for (counter = 0; counter < asect->lineno_count; counter++, src++)
4538
0
    {
4539
0
      struct internal_lineno dst;
4540
4541
0
      bfd_coff_swap_lineno_in (abfd, src, &dst);
4542
0
      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
0
      memset (&cache_ptr->u, 0, sizeof (cache_ptr->u));
4547
4548
0
      if (cache_ptr->line_number == 0)
4549
0
  {
4550
0
    combined_entry_type * ent;
4551
0
    unsigned long symndx;
4552
0
    coff_symbol_type *sym;
4553
4554
0
    have_func = false;
4555
0
    symndx = dst.l_addr.l_symndx;
4556
0
    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
0
    ent = obj_raw_syments (abfd) + symndx;
4568
    /* FIXME: We should not be casting between ints and
4569
       pointers like this.  */
4570
0
    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
0
    sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes);
4581
4582
    /* PR 17512 file: 078-10659-0.004  */
4583
0
    if (sym < obj_symbols (abfd)
4584
0
        || 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
0
    have_func = true;
4596
0
    nbr_func++;
4597
0
    cache_ptr->u.sym = (asymbol *) sym;
4598
0
    if (sym->lineno != NULL)
4599
0
      _bfd_error_handler
4600
        /* xgettext:c-format */
4601
0
        (_("%pB: warning: duplicate line number information for `%s'"),
4602
0
         abfd, bfd_asymbol_name (&sym->symbol));
4603
4604
0
    sym->lineno = cache_ptr;
4605
0
    if (sym->symbol.value < prev_offset)
4606
0
      ordered = false;
4607
0
    prev_offset = sym->symbol.value;
4608
0
  }
4609
0
      else if (!have_func)
4610
  /* Drop line information that has no associated function.
4611
     PR 17521: file: 078-10659-0.004.  */
4612
0
  continue;
4613
0
      else
4614
0
  cache_ptr->u.offset = dst.l_addr.l_paddr - bfd_section_vma (asect);
4615
0
      cache_ptr++;
4616
0
    }
4617
4618
0
  asect->lineno_count = cache_ptr - lineno_cache;
4619
0
  memset (cache_ptr, 0, sizeof (*cache_ptr));
4620
0
  free (native_lineno);
4621
4622
  /* On some systems (eg AIX5.3) the lineno table may not be sorted.  */
4623
0
  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
0
  return ret;
4687
0
}
Unexecuted instantiation: pei-i386.c:coff_slurp_line_table
Unexecuted instantiation: pe-x86_64.c:coff_slurp_line_table
Unexecuted instantiation: pei-x86_64.c:coff_slurp_line_table
Unexecuted instantiation: coff-x86_64.c:coff_slurp_line_table
Unexecuted instantiation: coff64-rs6000.c:coff_slurp_line_table
Unexecuted instantiation: pe-aarch64.c:coff_slurp_line_table
Unexecuted instantiation: pei-aarch64.c:coff_slurp_line_table
Unexecuted instantiation: pei-ia64.c:coff_slurp_line_table
Unexecuted instantiation: pei-loongarch64.c:coff_slurp_line_table
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
Unexecuted instantiation: coff-rs6000.c:coff_slurp_line_table
Unexecuted instantiation: coff-sh.c:coff_slurp_line_table
Unexecuted instantiation: coff-stgo32.c:coff_slurp_line_table
Unexecuted instantiation: coff-tic30.c:coff_slurp_line_table
Unexecuted instantiation: coff-tic4x.c:coff_slurp_line_table
Unexecuted instantiation: coff-tic54x.c:coff_slurp_line_table
Unexecuted instantiation: coff-z80.c:coff_slurp_line_table
Unexecuted instantiation: coff-z8k.c:coff_slurp_line_table
Unexecuted instantiation: pe-arm-wince.c:coff_slurp_line_table
Unexecuted instantiation: pe-arm.c:coff_slurp_line_table
Unexecuted instantiation: pe-i386.c:coff_slurp_line_table
Unexecuted instantiation: pe-mcore.c:coff_slurp_line_table
Unexecuted instantiation: pe-sh.c:coff_slurp_line_table
Unexecuted instantiation: pei-arm-wince.c:coff_slurp_line_table
Unexecuted instantiation: pei-arm.c:coff_slurp_line_table
Unexecuted instantiation: pei-mcore.c:coff_slurp_line_table
Unexecuted instantiation: pei-sh.c:coff_slurp_line_table
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
0
{
4696
0
  combined_entry_type *native_symbols;
4697
0
  coff_symbol_type *cached_area;
4698
0
  unsigned int *table_ptr;
4699
0
  unsigned int number_of_symbols = 0;
4700
0
  bool ret = true;
4701
0
  size_t amt;
4702
4703
0
  if (obj_symbols (abfd))
4704
0
    return true;
4705
4706
  /* Read in the symbol table.  */
4707
0
  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
0
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4712
0
       sizeof (*cached_area), &amt))
4713
0
    {
4714
0
      bfd_set_error (bfd_error_file_too_big);
4715
0
      return false;
4716
0
    }
4717
0
  cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
4718
0
  if (cached_area == NULL)
4719
0
    return false;
4720
4721
0
  if (_bfd_mul_overflow (obj_raw_syment_count (abfd),
4722
0
       sizeof (*table_ptr), &amt))
4723
0
    {
4724
0
      bfd_set_error (bfd_error_file_too_big);
4725
0
      return false;
4726
0
    }
4727
0
  table_ptr = (unsigned int *) bfd_zalloc (abfd, amt);
4728
0
  if (table_ptr == NULL)
4729
0
    return false;
4730
0
  else
4731
0
    {
4732
0
      coff_symbol_type *dst = cached_area;
4733
0
      unsigned int last_native_index = obj_raw_syment_count (abfd);
4734
0
      unsigned int this_index = 0;
4735
4736
0
      while (this_index < last_native_index)
4737
0
  {
4738
0
    combined_entry_type *src = native_symbols + this_index;
4739
0
    table_ptr[this_index] = number_of_symbols;
4740
4741
0
    dst->symbol.the_bfd = abfd;
4742
0
    BFD_ASSERT (src->is_sym);
4743
0
    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
0
    src->u.syment._n._n_n._n_zeroes = (uintptr_t) dst;
4746
0
    dst->symbol.section = coff_section_from_bfd_index (abfd,
4747
0
                 src->u.syment.n_scnum);
4748
0
    dst->symbol.flags = 0;
4749
    /* PR 17512: file: 079-7098-0.001:0.1.  */
4750
0
    dst->symbol.value = 0;
4751
0
    dst->done_lineno = false;
4752
4753
0
    switch (src->u.syment.n_sclass)
4754
0
      {
4755
0
      case C_EXT:
4756
0
      case C_WEAKEXT:
4757
#if defined ARM
4758
0
      case C_THUMBEXT:
4759
0
      case C_THUMBEXTFUNC:
4760
#endif
4761
#ifdef RS6000COFF_C
4762
0
      case C_HIDEXT:
4763
0
#ifndef AIX_WEAK_SUPPORT
4764
0
      case C_AIX_WEAKEXT:
4765
#endif
4766
#endif
4767
0
#ifdef C_SYSTEM
4768
0
      case C_SYSTEM: /* System Wide variable.  */
4769
0
#endif
4770
#ifdef COFF_WITH_PE
4771
      /* In PE, 0x68 (104) denotes a section symbol.  */
4772
0
      case C_SECTION:
4773
      /* In PE, 0x69 (105) denotes a weak external symbol.  */
4774
0
      case C_NT_WEAK:
4775
#endif
4776
0
        switch (coff_classify_symbol (abfd, &src->u.syment))
4777
0
    {
4778
0
    case COFF_SYMBOL_GLOBAL:
4779
0
      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
0
      if (ISFCN ((src->u.syment.n_type)))
4789
        /* A function ext does not go at the end of a
4790
           file.  */
4791
0
        dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
4792
0
      break;
4793
4794
0
    case COFF_SYMBOL_COMMON:
4795
0
      dst->symbol.section = bfd_com_section_ptr;
4796
0
      dst->symbol.value = src->u.syment.n_value;
4797
0
      break;
4798
4799
0
    case COFF_SYMBOL_UNDEFINED:
4800
0
      dst->symbol.section = bfd_und_section_ptr;
4801
0
      dst->symbol.value = 0;
4802
0
      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
      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
0
    }
4823
4824
#ifdef RS6000COFF_C
4825
        /* A symbol with a csect entry should not go at the end.  */
4826
0
        if (src->u.syment.n_numaux > 0)
4827
0
    dst->symbol.flags |= BSF_NOT_AT_END;
4828
#endif
4829
4830
#ifdef COFF_WITH_PE
4831
0
        if (src->u.syment.n_sclass == C_NT_WEAK)
4832
0
    dst->symbol.flags |= BSF_WEAK;
4833
4834
0
        if (src->u.syment.n_sclass == C_SECTION
4835
0
      && src->u.syment.n_scnum > 0)
4836
0
    dst->symbol.flags = BSF_LOCAL;
4837
#endif
4838
0
        if (src->u.syment.n_sclass == C_WEAKEXT
4839
#ifdef RS6000COFF_C
4840
0
      || src->u.syment.n_sclass == C_AIX_WEAKEXT
4841
#endif
4842
0
      )
4843
0
    dst->symbol.flags |= BSF_WEAK;
4844
4845
0
        break;
4846
4847
0
      case C_STAT:  /* Static.  */
4848
#if defined ARM
4849
0
      case C_THUMBSTAT:    /* Thumb static.  */
4850
0
      case C_THUMBLABEL:   /* Thumb label.  */
4851
0
      case C_THUMBSTATFUNC:/* Thumb static function.  */
4852
#endif
4853
#ifdef RS6000COFF_C
4854
0
      case C_DWARF:  /* A label in a dwarf section.  */
4855
0
      case C_INFO:  /* A label in a comment section.  */
4856
#endif
4857
0
      case C_LABEL:  /* Label.  */
4858
0
        if (src->u.syment.n_scnum == N_DEBUG)
4859
0
    dst->symbol.flags = BSF_DEBUGGING;
4860
0
        else
4861
0
    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
0
        if (dst->symbol.section)
4866
0
    {
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
0
    }
4876
0
        else
4877
0
    dst->symbol.value = src->u.syment.n_value;
4878
0
        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
0
      case C_EOS:   /* End of structure.  */
4885
0
      case C_REGPARM: /* Register parameter.  */
4886
0
      case C_REG:   /* register variable.  */
4887
        /* C_AUTOARG conflicts with TI COFF C_UEXT.  */
4888
0
      case C_TPDEF: /* Type definition.  */
4889
0
      case C_ARG:
4890
0
      case C_AUTO: /* Automatic variable.  */
4891
0
      case C_FIELD: /* Bit field.  */
4892
0
      case C_ENTAG: /* Enumeration tag.  */
4893
0
      case C_MOE:   /* Member of enumeration.  */
4894
0
      case C_MOU:   /* Member of union.  */
4895
0
      case C_UNTAG: /* Union tag.  */
4896
0
      case C_STRTAG: /* Structure tag.  */
4897
#ifdef RS6000COFF_C
4898
0
      case C_GSYM:
4899
0
      case C_LSYM:
4900
0
      case C_PSYM:
4901
0
      case C_RSYM:
4902
0
      case C_RPSYM:
4903
0
      case C_STSYM:
4904
0
      case C_TCSYM:
4905
0
      case C_BCOMM:
4906
0
      case C_ECOML:
4907
0
      case C_ECOMM:
4908
0
      case C_DECL:
4909
0
      case C_ENTRY:
4910
0
      case C_FUN:
4911
0
      case C_ESTAT:
4912
#endif
4913
0
        dst->symbol.flags |= BSF_DEBUGGING;
4914
0
        dst->symbol.value = (src->u.syment.n_value);
4915
0
        break;
4916
4917
#ifdef RS6000COFF_C
4918
0
      case C_BINCL: /* Beginning of include file.  */
4919
0
      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
0
        {
4925
0
    asection *sec;
4926
4927
0
    dst->symbol.flags = BSF_DEBUGGING;
4928
0
    for (sec = abfd->sections; sec != NULL; sec = sec->next)
4929
0
      if (sec->line_filepos <= (file_ptr) src->u.syment.n_value
4930
0
          && ((file_ptr) (sec->line_filepos
4931
0
              + sec->lineno_count * bfd_coff_linesz (abfd))
4932
0
        > (file_ptr) src->u.syment.n_value))
4933
0
        break;
4934
0
    if (sec == NULL)
4935
0
      dst->symbol.value = 0;
4936
0
    else
4937
0
      {
4938
0
        dst->symbol.section = sec;
4939
0
        dst->symbol.value = ((src->u.syment.n_value
4940
0
            - sec->line_filepos)
4941
0
           / bfd_coff_linesz (abfd));
4942
0
        src->fix_line = 1;
4943
0
      }
4944
0
        }
4945
0
        break;
4946
4947
0
      case C_BSTAT:
4948
0
        dst->symbol.flags = BSF_DEBUGGING;
4949
4950
0
        if (src->u.syment.n_value >= obj_raw_syment_count (abfd))
4951
0
    dst->symbol.value = 0;
4952
0
        else
4953
0
    {
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
0
      src->u.syment.n_value
4958
0
        = (uintptr_t) (native_symbols + src->u.syment.n_value);
4959
0
      dst->symbol.value = src->u.syment.n_value;
4960
0
      src->fix_value = 1;
4961
0
    }
4962
0
        break;
4963
0
#endif
4964
4965
0
      case C_BLOCK: /* ".bb" or ".eb".  */
4966
0
      case C_FCN:   /* ".bf" or ".ef" (or PE ".lf").  */
4967
0
      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
0
        if (strcmp (dst->symbol.name, ".bf") != 0)
4973
0
    {
4974
      /* PE uses funny values for .ef and .lf; don't
4975
         relocate them.  */
4976
0
      dst->symbol.flags = BSF_DEBUGGING;
4977
0
    }
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
0
        dst->symbol.flags = BSF_LOCAL;
4984
        dst->symbol.value = (src->u.syment.n_value
4985
           - dst->symbol.section->vma);
4986
#endif
4987
0
        break;
4988
4989
0
      case C_STATLAB: /* Static load time label.  */
4990
0
        dst->symbol.value = src->u.syment.n_value;
4991
0
        dst->symbol.flags = BSF_GLOBAL;
4992
0
        break;
4993
4994
0
      case C_NULL:
4995
        /* PE DLLs sometimes have zeroed out symbols for some
4996
     reason.  Just ignore them without a warning.  */
4997
0
        if (src->u.syment.n_type == 0
4998
0
      && src->u.syment.n_value == 0
4999
0
      && src->u.syment.n_scnum == 0)
5000
0
    break;
5001
#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
#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
0
      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
0
        dst->symbol.flags = BSF_DEBUGGING;
5034
0
        dst->symbol.value = (src->u.syment.n_value);
5035
0
        break;
5036
0
      }
5037
5038
0
    dst->native = src;
5039
0
    dst->symbol.udata.i = 0;
5040
0
    dst->lineno = NULL;
5041
5042
0
    this_index += (src->u.syment.n_numaux) + 1;
5043
0
    dst++;
5044
0
    number_of_symbols++;
5045
0
  }
5046
0
    }
5047
5048
0
  obj_symbols (abfd) = cached_area;
5049
0
  obj_raw_syments (abfd) = native_symbols;
5050
5051
0
  abfd->symcount = number_of_symbols;
5052
0
  obj_convert (abfd) = table_ptr;
5053
  /* Slurp the line tables for each section too.  */
5054
0
  {
5055
0
    asection *p;
5056
5057
0
    p = abfd->sections;
5058
0
    while (p)
5059
0
      {
5060
0
  if (! coff_slurp_line_table (abfd, p))
5061
0
    return false;
5062
0
  p = p->next;
5063
0
      }
5064
0
  }
5065
5066
0
  return ret;
5067
0
}
Unexecuted instantiation: pei-i386.c:coff_slurp_symbol_table
Unexecuted instantiation: pe-x86_64.c:coff_slurp_symbol_table
Unexecuted instantiation: pei-x86_64.c:coff_slurp_symbol_table
Unexecuted instantiation: coff-x86_64.c:coff_slurp_symbol_table
Unexecuted instantiation: coff64-rs6000.c:coff_slurp_symbol_table
Unexecuted instantiation: pe-aarch64.c:coff_slurp_symbol_table
Unexecuted instantiation: pei-aarch64.c:coff_slurp_symbol_table
Unexecuted instantiation: pei-ia64.c:coff_slurp_symbol_table
Unexecuted instantiation: pei-loongarch64.c:coff_slurp_symbol_table
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
Unexecuted instantiation: coff-rs6000.c:coff_slurp_symbol_table
Unexecuted instantiation: coff-sh.c:coff_slurp_symbol_table
Unexecuted instantiation: coff-stgo32.c:coff_slurp_symbol_table
Unexecuted instantiation: coff-tic30.c:coff_slurp_symbol_table
Unexecuted instantiation: coff-tic4x.c:coff_slurp_symbol_table
Unexecuted instantiation: coff-tic54x.c:coff_slurp_symbol_table
Unexecuted instantiation: coff-z80.c:coff_slurp_symbol_table
Unexecuted instantiation: coff-z8k.c:coff_slurp_symbol_table
Unexecuted instantiation: pe-arm-wince.c:coff_slurp_symbol_table
Unexecuted instantiation: pe-arm.c:coff_slurp_symbol_table
Unexecuted instantiation: pe-i386.c:coff_slurp_symbol_table
Unexecuted instantiation: pe-mcore.c:coff_slurp_symbol_table
Unexecuted instantiation: pe-sh.c:coff_slurp_symbol_table
Unexecuted instantiation: pei-arm-wince.c:coff_slurp_symbol_table
Unexecuted instantiation: pei-arm.c:coff_slurp_symbol_table
Unexecuted instantiation: pei-mcore.c:coff_slurp_symbol_table
Unexecuted instantiation: pei-sh.c:coff_slurp_symbol_table
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
0
{
5077
  /* FIXME: This partially duplicates the switch in
5078
     coff_slurp_symbol_table.  */
5079
0
  switch (syment->n_sclass)
5080
0
    {
5081
0
    case C_EXT:
5082
0
    case C_WEAKEXT:
5083
#ifdef ARM
5084
0
    case C_THUMBEXT:
5085
0
    case C_THUMBEXTFUNC:
5086
#endif
5087
#ifdef RS6000COFF_C
5088
0
    case C_HIDEXT:
5089
0
#ifndef AIX_WEAK_SUPPORT
5090
0
    case C_AIX_WEAKEXT:
5091
#endif
5092
#endif
5093
0
#ifdef C_SYSTEM
5094
0
    case C_SYSTEM:
5095
0
#endif
5096
#ifdef COFF_WITH_PE
5097
0
    case C_NT_WEAK:
5098
#endif
5099
0
      if (syment->n_scnum == 0)
5100
0
  {
5101
0
    if (syment->n_value == 0)
5102
0
      return COFF_SYMBOL_UNDEFINED;
5103
0
    else
5104
0
      return COFF_SYMBOL_COMMON;
5105
0
  }
5106
#ifdef RS6000COFF_C
5107
0
      if (syment->n_sclass == C_HIDEXT)
5108
0
  return COFF_SYMBOL_LOCAL;
5109
0
#endif
5110
0
      return COFF_SYMBOL_GLOBAL;
5111
5112
0
    default:
5113
0
      break;
5114
0
    }
5115
5116
#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
}
Unexecuted instantiation: pei-i386.c:coff_classify_symbol
Unexecuted instantiation: pe-x86_64.c:coff_classify_symbol
Unexecuted instantiation: pei-x86_64.c:coff_classify_symbol
Unexecuted instantiation: coff-x86_64.c:coff_classify_symbol
Unexecuted instantiation: coff64-rs6000.c:coff_classify_symbol
Unexecuted instantiation: pe-aarch64.c:coff_classify_symbol
Unexecuted instantiation: pei-aarch64.c:coff_classify_symbol
Unexecuted instantiation: pei-ia64.c:coff_classify_symbol
Unexecuted instantiation: pei-loongarch64.c:coff_classify_symbol
Unexecuted instantiation: cf-i386lynx.c:coff_classify_symbol
Unexecuted instantiation: coff-go32.c:coff_classify_symbol
Unexecuted instantiation: coff-i386.c:coff_classify_symbol
Unexecuted instantiation: coff-rs6000.c:coff_classify_symbol
Unexecuted instantiation: coff-sh.c:coff_classify_symbol
Unexecuted instantiation: coff-stgo32.c:coff_classify_symbol
Unexecuted instantiation: coff-tic30.c:coff_classify_symbol
Unexecuted instantiation: coff-tic4x.c:coff_classify_symbol
Unexecuted instantiation: coff-tic54x.c:coff_classify_symbol
Unexecuted instantiation: coff-z80.c:coff_classify_symbol
Unexecuted instantiation: coff-z8k.c:coff_classify_symbol
Unexecuted instantiation: pe-arm-wince.c:coff_classify_symbol
Unexecuted instantiation: pe-arm.c:coff_classify_symbol
Unexecuted instantiation: pe-i386.c:coff_classify_symbol
Unexecuted instantiation: pe-mcore.c:coff_classify_symbol
Unexecuted instantiation: pe-sh.c:coff_classify_symbol
Unexecuted instantiation: pei-arm-wince.c:coff_classify_symbol
Unexecuted instantiation: pei-arm.c:coff_classify_symbol
Unexecuted instantiation: pei-mcore.c:coff_classify_symbol
Unexecuted instantiation: pei-sh.c:coff_classify_symbol
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
26.4k
{
5706
26.4k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
26.4k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
26.4k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
26.4k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
26.4k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
26.4k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
26.4k
  filehdr_dst->f_symptr =
5714
26.4k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
26.4k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
26.4k
  filehdr_dst->f_opthdr = 0;
5717
26.4k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
26.4k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
26.4k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
26.4k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
26.4k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
26.3k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
26.4k
}
pe-x86_64.c:coff_bigobj_swap_filehdr_in
Line
Count
Source
5705
13.2k
{
5706
13.2k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
13.2k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
13.2k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
13.2k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
13.2k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
13.2k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
13.2k
  filehdr_dst->f_symptr =
5714
13.2k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
13.2k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
13.2k
  filehdr_dst->f_opthdr = 0;
5717
13.2k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
13.2k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
13.2k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
13.2k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
13.2k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
13.1k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
13.2k
}
pe-i386.c:coff_bigobj_swap_filehdr_in
Line
Count
Source
5705
13.2k
{
5706
13.2k
  struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src =
5707
13.2k
    (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src;
5708
13.2k
  struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
5709
5710
13.2k
  filehdr_dst->f_magic  = H_GET_16 (abfd, filehdr_src->Machine);
5711
13.2k
  filehdr_dst->f_nscns  = H_GET_32 (abfd, filehdr_src->NumberOfSections);
5712
13.2k
  filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp);
5713
13.2k
  filehdr_dst->f_symptr =
5714
13.2k
    GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable);
5715
13.2k
  filehdr_dst->f_nsyms  = H_GET_32 (abfd, filehdr_src->NumberOfSymbols);
5716
13.2k
  filehdr_dst->f_opthdr = 0;
5717
13.2k
  filehdr_dst->f_flags  = 0;
5718
5719
  /* Check other magic numbers.  */
5720
13.2k
  if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN
5721
13.2k
      || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff
5722
13.2k
      || H_GET_16 (abfd, filehdr_src->Version) != 2
5723
13.2k
      || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0)
5724
13.1k
    filehdr_dst->f_opthdr = 0xffff;
5725
5726
  /* Note that CLR metadata are ignored.  */
5727
13.2k
}
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
1.04k
{
5755
1.04k
  SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1;
5756
1.04k
  struct internal_syment *in = (struct internal_syment *) in1;
5757
5758
1.04k
  if (ext->e.e_name[0] == 0)
5759
790
    {
5760
790
      in->_n._n_n._n_zeroes = 0;
5761
790
      in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
5762
790
    }
5763
256
  else
5764
256
    {
5765
#if SYMNMLEN != E_SYMNMLEN
5766
#error we need to cope with truncating or extending SYMNMLEN
5767
#else
5768
256
      memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
5769
256
#endif
5770
256
    }
5771
5772
1.04k
  in->n_value = H_GET_32 (abfd, ext->e_value);
5773
1.04k
  BFD_ASSERT (sizeof (in->n_scnum) >= 4);
5774
1.04k
  in->n_scnum = H_GET_32 (abfd, ext->e_scnum);
5775
1.04k
  in->n_type = H_GET_16 (abfd, ext->e_type);
5776
1.04k
  in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
5777
1.04k
  in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
5778
1.04k
}
pe-x86_64.c:coff_bigobj_swap_sym_in
Line
Count
Source
5754
251
{
5755
251
  SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1;
5756
251
  struct internal_syment *in = (struct internal_syment *) in1;
5757
5758
251
  if (ext->e.e_name[0] == 0)
5759
162
    {
5760
162
      in->_n._n_n._n_zeroes = 0;
5761
162
      in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
5762
162
    }
5763
89
  else
5764
89
    {
5765
#if SYMNMLEN != E_SYMNMLEN
5766
#error we need to cope with truncating or extending SYMNMLEN
5767
#else
5768
89
      memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
5769
89
#endif
5770
89
    }
5771
5772
251
  in->n_value = H_GET_32 (abfd, ext->e_value);
5773
251
  BFD_ASSERT (sizeof (in->n_scnum) >= 4);
5774
251
  in->n_scnum = H_GET_32 (abfd, ext->e_scnum);
5775
251
  in->n_type = H_GET_16 (abfd, ext->e_type);
5776
251
  in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
5777
251
  in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
5778
251
}
pe-i386.c:coff_bigobj_swap_sym_in
Line
Count
Source
5754
795
{
5755
795
  SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1;
5756
795
  struct internal_syment *in = (struct internal_syment *) in1;
5757
5758
795
  if (ext->e.e_name[0] == 0)
5759
628
    {
5760
628
      in->_n._n_n._n_zeroes = 0;
5761
628
      in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
5762
628
    }
5763
167
  else
5764
167
    {
5765
#if SYMNMLEN != E_SYMNMLEN
5766
#error we need to cope with truncating or extending SYMNMLEN
5767
#else
5768
167
      memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
5769
167
#endif
5770
167
    }
5771
5772
795
  in->n_value = H_GET_32 (abfd, ext->e_value);
5773
795
  BFD_ASSERT (sizeof (in->n_scnum) >= 4);
5774
795
  in->n_scnum = H_GET_32 (abfd, ext->e_scnum);
5775
795
  in->n_type = H_GET_16 (abfd, ext->e_type);
5776
795
  in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
5777
795
  in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
5778
795
}
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
68
{
5819
68
  AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1;
5820
68
  union internal_auxent *in = (union internal_auxent *) in1;
5821
5822
  /* Make sure that all fields in the aux structure are
5823
     initialised.  */
5824
68
  memset (in, 0, sizeof * in);
5825
68
  switch (in_class)
5826
68
    {
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
3
    case C_STAT:
5839
4
    case C_LEAFSTAT:
5840
5
    case C_HIDDEN:
5841
5
      if (type == T_NULL)
5842
1
  {
5843
1
    in->x_scn.x_scnlen = H_GET_32 (abfd, ext->Section.Length);
5844
1
    in->x_scn.x_nreloc =
5845
1
      H_GET_16 (abfd, ext->Section.NumberOfRelocations);
5846
1
    in->x_scn.x_nlinno =
5847
1
      H_GET_16 (abfd, ext->Section.NumberOfLinenumbers);
5848
1
    in->x_scn.x_checksum = H_GET_32 (abfd, ext->Section.Checksum);
5849
1
    in->x_scn.x_associated = H_GET_16 (abfd, ext->Section.Number)
5850
1
      | (H_GET_16 (abfd, ext->Section.HighNumber) << 16);
5851
1
    in->x_scn.x_comdat = H_GET_8 (abfd, ext->Section.Selection);
5852
1
    return;
5853
1
  }
5854
4
      break;
5855
5856
63
    default:
5857
63
      in->x_sym.x_tagndx.u32 = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex);
5858
      /* Characteristics is ignored.  */
5859
63
      break;
5860
68
    }
5861
68
}
pe-x86_64.c:coff_bigobj_swap_aux_in
Line
Count
Source
5818
30
{
5819
30
  AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1;
5820
30
  union internal_auxent *in = (union internal_auxent *) in1;
5821
5822
  /* Make sure that all fields in the aux structure are
5823
     initialised.  */
5824
30
  memset (in, 0, sizeof * in);
5825
30
  switch (in_class)
5826
30
    {
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
2
    case C_STAT:
5839
2
    case C_LEAFSTAT:
5840
2
    case C_HIDDEN:
5841
2
      if (type == T_NULL)
5842
1
  {
5843
1
    in->x_scn.x_scnlen = H_GET_32 (abfd, ext->Section.Length);
5844
1
    in->x_scn.x_nreloc =
5845
1
      H_GET_16 (abfd, ext->Section.NumberOfRelocations);
5846
1
    in->x_scn.x_nlinno =
5847
1
      H_GET_16 (abfd, ext->Section.NumberOfLinenumbers);
5848
1
    in->x_scn.x_checksum = H_GET_32 (abfd, ext->Section.Checksum);
5849
1
    in->x_scn.x_associated = H_GET_16 (abfd, ext->Section.Number)
5850
1
      | (H_GET_16 (abfd, ext->Section.HighNumber) << 16);
5851
1
    in->x_scn.x_comdat = H_GET_8 (abfd, ext->Section.Selection);
5852
1
    return;
5853
1
  }
5854
1
      break;
5855
5856
28
    default:
5857
28
      in->x_sym.x_tagndx.u32 = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex);
5858
      /* Characteristics is ignored.  */
5859
28
      break;
5860
30
    }
5861
30
}
pe-i386.c:coff_bigobj_swap_aux_in
Line
Count
Source
5818
38
{
5819
38
  AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1;
5820
38
  union internal_auxent *in = (union internal_auxent *) in1;
5821
5822
  /* Make sure that all fields in the aux structure are
5823
     initialised.  */
5824
38
  memset (in, 0, sizeof * in);
5825
38
  switch (in_class)
5826
38
    {
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
1
    case C_STAT:
5839
2
    case C_LEAFSTAT:
5840
3
    case C_HIDDEN:
5841
3
      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
3
      break;
5855
5856
35
    default:
5857
35
      in->x_sym.x_tagndx.u32 = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex);
5858
      /* Characteristics is ignored.  */
5859
35
      break;
5860
38
    }
5861
38
}
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
};