| 1 |
/* Support for the generic parts of most COFF variants, for BFD. |
/* Support for the generic parts of most COFF variants, for BFD. |
| 2 |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
| 3 |
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
| 4 |
Free Software Foundation, Inc. |
Free Software Foundation, Inc. |
| 5 |
Written by Cygnus Support. |
Written by Cygnus Support. |
| 6 |
|
|
| 109 |
target. |
target. |
| 110 |
|
|
| 111 |
SUBSUBSECTION |
SUBSUBSECTION |
| 112 |
|
Coff long section names |
| 113 |
|
|
| 114 |
|
In the standard Coff object format, section names are limited to |
| 115 |
|
the eight bytes available in the @code{s_name} field of the |
| 116 |
|
@code{SCNHDR} section header structure. The format requires the |
| 117 |
|
field to be NUL-padded, but not necessarily NUL-terminated, so |
| 118 |
|
the longest section names permitted are a full eight characters. |
| 119 |
|
|
| 120 |
|
The Microsoft PE variants of the Coff object file format add |
| 121 |
|
an extension to support the use of long section names. This |
| 122 |
|
extension is defined in section 4 of the Microsoft PE/COFF |
| 123 |
|
specification (rev 8.1). If a section name is too long to fit |
| 124 |
|
into the section header's @code{s_name} field, it is instead |
| 125 |
|
placed into the string table, and the @code{s_name} field is |
| 126 |
|
filled with a slash ("/") followed by the ASCII decimal |
| 127 |
|
representation of the offset of the full name relative to the |
| 128 |
|
string table base. |
| 129 |
|
|
| 130 |
|
Note that this implies that the extension can only be used in object |
| 131 |
|
files, as executables do not contain a string table. The standard |
| 132 |
|
specifies that long section names from objects emitted into executable |
| 133 |
|
images are to be truncated. |
| 134 |
|
|
| 135 |
|
However, as a GNU extension, BFD can generate executable images |
| 136 |
|
that contain a string table and long section names. This |
| 137 |
|
would appear to be technically valid, as the standard only says |
| 138 |
|
that Coff debugging information is deprecated, not forbidden, |
| 139 |
|
and in practice it works, although some tools that parse PE files |
| 140 |
|
expecting the MS standard format may become confused; @file{PEview} is |
| 141 |
|
one known example. |
| 142 |
|
|
| 143 |
|
The functionality is supported in BFD by code implemented under |
| 144 |
|
the control of the macro @code{COFF_LONG_SECTION_NAMES}. If not |
| 145 |
|
defined, the format does not support long section names in any way. |
| 146 |
|
If defined, it is used to initialise a flag, |
| 147 |
|
@code{_bfd_coff_long_section_names}, and a hook function pointer, |
| 148 |
|
@code{_bfd_coff_set_long_section_names}, in the Coff backend data |
| 149 |
|
structure. The flag controls the generation of long section names |
| 150 |
|
in output BFDs at runtime; if it is false, as it will be by default |
| 151 |
|
when generating an executable image, long section names are truncated; |
| 152 |
|
if true, the long section names extension is employed. The hook |
| 153 |
|
points to a function that allows the value of the flag to be altered |
| 154 |
|
at runtime, on formats that support long section names at all; on |
| 155 |
|
other formats it points to a stub that returns an error indication. |
| 156 |
|
|
| 157 |
|
With input BFDs, the flag is set according to whether any long section |
| 158 |
|
names are detected while reading the section headers. For a completely |
| 159 |
|
new BFD, the flag is set to the default for the target format. This |
| 160 |
|
information can be used by a client of the BFD library when deciding |
| 161 |
|
what output format to generate, and means that a BFD that is opened |
| 162 |
|
for read and subsequently converted to a writeable BFD and modified |
| 163 |
|
in-place will retain whatever format it had on input. |
| 164 |
|
|
| 165 |
|
If @code{COFF_LONG_SECTION_NAMES} is simply defined (blank), or is |
| 166 |
|
defined to the value "1", then long section names are enabled by |
| 167 |
|
default; if it is defined to the value zero, they are disabled by |
| 168 |
|
default (but still accepted in input BFDs). The header @file{coffcode.h} |
| 169 |
|
defines a macro, @code{COFF_DEFAULT_LONG_SECTION_NAMES}, which is |
| 170 |
|
used in the backends to initialise the backend data structure fields |
| 171 |
|
appropriately; see the comments for further detail. |
| 172 |
|
|
| 173 |
|
SUBSUBSECTION |
| 174 |
Bit twiddling |
Bit twiddling |
| 175 |
|
|
| 176 |
Each flavour of coff supported in BFD has its own header file |
Each flavour of coff supported in BFD has its own header file |
| 371 |
|
|
| 372 |
#define DOT_DEBUG ".debug" |
#define DOT_DEBUG ".debug" |
| 373 |
#define GNU_LINKONCE_WI ".gnu.linkonce.wi." |
#define GNU_LINKONCE_WI ".gnu.linkonce.wi." |
| 374 |
|
#define DOT_RELOC ".reloc" |
| 375 |
|
|
| 376 |
|
#if defined (COFF_LONG_SECTION_NAMES) |
| 377 |
|
/* Needed to expand the inputs to BLANKOR1TOODD. */ |
| 378 |
|
#define COFFLONGSECTIONCATHELPER(x,y) x ## y |
| 379 |
|
/* If the input macro Y is blank or '1', return an odd number; if it is |
| 380 |
|
'0', return an even number. Result undefined in all other cases. */ |
| 381 |
|
#define BLANKOR1TOODD(y) COFFLONGSECTIONCATHELPER(1,y) |
| 382 |
|
/* Defined to numerical 0 or 1 according to whether generation of long |
| 383 |
|
section names is disabled or enabled by default. */ |
| 384 |
|
#define COFF_ENABLE_LONG_SECTION_NAMES (BLANKOR1TOODD(COFF_LONG_SECTION_NAMES) & 1) |
| 385 |
|
/* Where long section names are supported, we allow them to be enabled |
| 386 |
|
and disabled at runtime, so select an appropriate hook function for |
| 387 |
|
_bfd_coff_set_long_section_names. */ |
| 388 |
|
#define COFF_LONG_SECTION_NAMES_SETTER bfd_coff_set_long_section_names_allowed |
| 389 |
|
#else /* !defined (COFF_LONG_SECTION_NAMES) */ |
| 390 |
|
/* If long section names are not supported, this stub disallows any |
| 391 |
|
attempt to enable them at run-time. */ |
| 392 |
|
#define COFF_LONG_SECTION_NAMES_SETTER bfd_coff_set_long_section_names_disallowed |
| 393 |
|
#endif /* defined (COFF_LONG_SECTION_NAMES) */ |
| 394 |
|
|
| 395 |
|
/* Define a macro that can be used to initialise both the fields relating |
| 396 |
|
to long section names in the backend data struct simultaneously. */ |
| 397 |
|
#if COFF_ENABLE_LONG_SECTION_NAMES |
| 398 |
|
#define COFF_DEFAULT_LONG_SECTION_NAMES (TRUE), COFF_LONG_SECTION_NAMES_SETTER |
| 399 |
|
#else /* !COFF_ENABLE_LONG_SECTION_NAMES */ |
| 400 |
|
#define COFF_DEFAULT_LONG_SECTION_NAMES (FALSE), COFF_LONG_SECTION_NAMES_SETTER |
| 401 |
|
#endif /* COFF_ENABLE_LONG_SECTION_NAMES */ |
| 402 |
|
|
| 403 |
|
#if defined (COFF_LONG_SECTION_NAMES) |
| 404 |
|
static bfd_boolean bfd_coff_set_long_section_names_allowed |
| 405 |
|
(bfd *, int); |
| 406 |
|
#else /* !defined (COFF_LONG_SECTION_NAMES) */ |
| 407 |
|
static bfd_boolean bfd_coff_set_long_section_names_disallowed |
| 408 |
|
(bfd *, int); |
| 409 |
|
#endif /* defined (COFF_LONG_SECTION_NAMES) */ |
| 410 |
static long sec_to_styp_flags |
static long sec_to_styp_flags |
| 411 |
(const char *, flagword); |
(const char *, flagword); |
| 412 |
static bfd_boolean styp_to_sec_flags |
static bfd_boolean styp_to_sec_flags |
| 469 |
|
|
| 470 |
/* void warning(); */ |
/* void warning(); */ |
| 471 |
|
|
| 472 |
|
#if defined (COFF_LONG_SECTION_NAMES) |
| 473 |
|
static bfd_boolean |
| 474 |
|
bfd_coff_set_long_section_names_allowed (bfd *abfd, int enable) |
| 475 |
|
{ |
| 476 |
|
coff_backend_info (abfd)->_bfd_coff_long_section_names = enable; |
| 477 |
|
return TRUE; |
| 478 |
|
} |
| 479 |
|
#else /* !defined (COFF_LONG_SECTION_NAMES) */ |
| 480 |
|
static bfd_boolean |
| 481 |
|
bfd_coff_set_long_section_names_disallowed (bfd *abfd, int enable) |
| 482 |
|
{ |
| 483 |
|
(void) abfd; |
| 484 |
|
(void) enable; |
| 485 |
|
return FALSE; |
| 486 |
|
} |
| 487 |
|
#endif /* defined (COFF_LONG_SECTION_NAMES) */ |
| 488 |
|
|
| 489 |
/* Return a word with STYP_* (scnhdr.s_flags) flags set to represent |
/* Return a word with STYP_* (scnhdr.s_flags) flags set to represent |
| 490 |
the incoming SEC_* flags. The inverse of this function is |
the incoming SEC_* flags. The inverse of this function is |
| 491 |
styp_to_sec_flags(). NOTE: If you add to/change this routine, you |
styp_to_sec_flags(). NOTE: If you add to/change this routine, you |
| 646 |
/* FIXME: There is no gas syntax to specify the debug section flag. */ |
/* FIXME: There is no gas syntax to specify the debug section flag. */ |
| 647 |
if (CONST_STRNEQ (sec_name, DOT_DEBUG) |
if (CONST_STRNEQ (sec_name, DOT_DEBUG) |
| 648 |
|| CONST_STRNEQ (sec_name, GNU_LINKONCE_WI)) |
|| CONST_STRNEQ (sec_name, GNU_LINKONCE_WI)) |
| 649 |
sec_flags = SEC_DEBUGGING; |
sec_flags = SEC_DEBUGGING | SEC_READONLY; |
| 650 |
|
|
| 651 |
/* skip LOAD */ |
/* skip LOAD */ |
| 652 |
/* READONLY later */ |
/* READONLY later */ |
| 675 |
/* skip LINK_DUPLICATES */ |
/* skip LINK_DUPLICATES */ |
| 676 |
/* skip LINKER_CREATED */ |
/* skip LINKER_CREATED */ |
| 677 |
|
|
| 678 |
if (sec_flags & (SEC_ALLOC | SEC_LOAD)) |
if ((sec_flags & SEC_COFF_NOREAD) == 0) |
| 679 |
{ |
styp_flags |= IMAGE_SCN_MEM_READ; /* Invert NOREAD for read. */ |
| 680 |
/* For now, the read/write bits are mapped onto SEC_READONLY, even |
if ((sec_flags & SEC_READONLY) == 0) |
| 681 |
though the semantics don't quite match. The bits from the input |
styp_flags |= IMAGE_SCN_MEM_WRITE; /* Invert READONLY for write. */ |
| 682 |
are retained in pei_section_data(abfd, section)->pe_flags. */ |
if (sec_flags & SEC_CODE) |
| 683 |
styp_flags |= IMAGE_SCN_MEM_READ; /* Always readable. */ |
styp_flags |= IMAGE_SCN_MEM_EXECUTE; /* CODE->EXECUTE. */ |
| 684 |
if ((sec_flags & SEC_READONLY) == 0) |
if (sec_flags & SEC_COFF_SHARED) |
| 685 |
styp_flags |= IMAGE_SCN_MEM_WRITE; /* Invert READONLY for write. */ |
styp_flags |= IMAGE_SCN_MEM_SHARED; /* Shared remains meaningful. */ |
|
if (sec_flags & SEC_CODE) |
|
|
styp_flags |= IMAGE_SCN_MEM_EXECUTE; /* CODE->EXECUTE. */ |
|
|
if (sec_flags & SEC_COFF_SHARED) |
|
|
styp_flags |= IMAGE_SCN_MEM_SHARED; /* Shared remains meaningful. */ |
|
|
} |
|
| 686 |
|
|
| 687 |
return styp_flags; |
return styp_flags; |
| 688 |
} |
} |
| 945 |
but there's some checking we can do to be |
but there's some checking we can do to be |
| 946 |
sure. */ |
sure. */ |
| 947 |
|
|
| 948 |
if (! (isym.n_sclass == C_STAT |
if (! ((isym.n_sclass == C_STAT |
| 949 |
|
|| isym.n_sclass == C_EXT) |
| 950 |
&& isym.n_type == T_NULL |
&& isym.n_type == T_NULL |
| 951 |
&& isym.n_value == 0)) |
&& isym.n_value == 0)) |
| 952 |
abort (); |
abort (); |
| 956 |
names like .text$foo__Fv (in the case of a |
names like .text$foo__Fv (in the case of a |
| 957 |
function). See comment above for more. */ |
function). See comment above for more. */ |
| 958 |
|
|
| 959 |
if (strcmp (name, symname) != 0) |
if (isym.n_sclass == C_STAT && strcmp (name, symname) != 0) |
| 960 |
_bfd_error_handler (_("%B: warning: COMDAT symbol '%s' does not match section name '%s'"), |
_bfd_error_handler (_("%B: warning: COMDAT symbol '%s' does not match section name '%s'"), |
| 961 |
abfd, symname, name); |
abfd, symname, name); |
| 962 |
|
|
| 1122 |
/* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ |
/* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ |
| 1123 |
sec_flags = SEC_READONLY; |
sec_flags = SEC_READONLY; |
| 1124 |
|
|
| 1125 |
|
/* If section disallows read, then set the NOREAD flag. */ |
| 1126 |
|
if ((styp_flags & IMAGE_SCN_MEM_READ) == 0) |
| 1127 |
|
sec_flags |= SEC_COFF_NOREAD; |
| 1128 |
|
|
| 1129 |
/* Process each flag bit in styp_flags in turn. */ |
/* Process each flag bit in styp_flags in turn. */ |
| 1130 |
while (styp_flags) |
while (styp_flags) |
| 1131 |
{ |
{ |
| 1158 |
break; |
break; |
| 1159 |
#endif |
#endif |
| 1160 |
case IMAGE_SCN_MEM_READ: |
case IMAGE_SCN_MEM_READ: |
| 1161 |
/* Ignored, assume it always to be true. */ |
sec_flags &= ~SEC_COFF_NOREAD; |
| 1162 |
break; |
break; |
| 1163 |
case IMAGE_SCN_TYPE_NO_PAD: |
case IMAGE_SCN_TYPE_NO_PAD: |
| 1164 |
/* Skip. */ |
/* Skip. */ |
| 1183 |
sec_flags &= ~ SEC_READONLY; |
sec_flags &= ~ SEC_READONLY; |
| 1184 |
break; |
break; |
| 1185 |
case IMAGE_SCN_MEM_DISCARDABLE: |
case IMAGE_SCN_MEM_DISCARDABLE: |
| 1186 |
/* The MS PE spec sets the DISCARDABLE flag on .reloc sections |
/* The MS PE spec says that debug sections are DISCARDABLE, |
| 1187 |
but we do not want them to be labelled as debug section, since |
but the presence of a DISCARDABLE flag does not necessarily |
| 1188 |
then strip would remove them. */ |
mean that a given section contains debug information. Thus |
| 1189 |
if (! CONST_STRNEQ (name, ".reloc")) |
we only set the SEC_DEBUGGING flag on sections that we |
| 1190 |
|
recognise as containing debug information. */ |
| 1191 |
|
if (CONST_STRNEQ (name, DOT_DEBUG) |
| 1192 |
|
#ifdef _COMMENT |
| 1193 |
|
|| strcmp (name, _COMMENT) == 0 |
| 1194 |
|
#endif |
| 1195 |
|
#ifdef COFF_LONG_SECTION_NAMES |
| 1196 |
|
|| CONST_STRNEQ (name, GNU_LINKONCE_WI) |
| 1197 |
|
#endif |
| 1198 |
|
|| CONST_STRNEQ (name, ".stab")) |
| 1199 |
sec_flags |= SEC_DEBUGGING; |
sec_flags |= SEC_DEBUGGING; |
| 1200 |
break; |
break; |
| 1201 |
case IMAGE_SCN_MEM_SHARED: |
case IMAGE_SCN_MEM_SHARED: |
| 1328 |
. unsigned int _bfd_linesz; |
. unsigned int _bfd_linesz; |
| 1329 |
. unsigned int _bfd_filnmlen; |
. unsigned int _bfd_filnmlen; |
| 1330 |
. bfd_boolean _bfd_coff_long_filenames; |
. bfd_boolean _bfd_coff_long_filenames; |
| 1331 |
|
. |
| 1332 |
. bfd_boolean _bfd_coff_long_section_names; |
. bfd_boolean _bfd_coff_long_section_names; |
| 1333 |
|
. bfd_boolean (*_bfd_coff_set_long_section_names) |
| 1334 |
|
. (bfd *, int); |
| 1335 |
|
. |
| 1336 |
. unsigned int _bfd_coff_default_section_alignment_power; |
. unsigned int _bfd_coff_default_section_alignment_power; |
| 1337 |
. bfd_boolean _bfd_coff_force_symnames_in_strings; |
. bfd_boolean _bfd_coff_force_symnames_in_strings; |
| 1338 |
. unsigned int _bfd_coff_debug_string_prefix_length; |
. unsigned int _bfd_coff_debug_string_prefix_length; |
| 1469 |
. (coff_backend_info (abfd)->_bfd_coff_long_filenames) |
. (coff_backend_info (abfd)->_bfd_coff_long_filenames) |
| 1470 |
.#define bfd_coff_long_section_names(abfd) \ |
.#define bfd_coff_long_section_names(abfd) \ |
| 1471 |
. (coff_backend_info (abfd)->_bfd_coff_long_section_names) |
. (coff_backend_info (abfd)->_bfd_coff_long_section_names) |
| 1472 |
|
.#define bfd_coff_set_long_section_names(abfd, enable) \ |
| 1473 |
|
. ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable)) |
| 1474 |
.#define bfd_coff_default_section_alignment_power(abfd) \ |
.#define bfd_coff_default_section_alignment_power(abfd) \ |
| 1475 |
. (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) |
. (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) |
| 1476 |
.#define bfd_coff_swap_filehdr_in(abfd, i,o) \ |
.#define bfd_coff_swap_filehdr_in(abfd, i,o) \ |
| 1561 |
.#define bfd_coff_print_pdata(a,p) \ |
.#define bfd_coff_print_pdata(a,p) \ |
| 1562 |
. ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p)) |
. ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p)) |
| 1563 |
. |
. |
| 1564 |
|
.{* Macro: Returns true if the bfd is a PE executable as opposed to a |
| 1565 |
|
. PE object file. *} |
| 1566 |
|
.#define bfd_pei_p(abfd) \ |
| 1567 |
|
. (CONST_STRNEQ ((abfd)->xvec->name, "pei-")) |
| 1568 |
*/ |
*/ |
| 1569 |
|
|
| 1570 |
/* See whether the magic number matches. */ |
/* See whether the magic number matches. */ |
| 2429 |
#define FORCE_SYMNAMES_IN_STRINGS |
#define FORCE_SYMNAMES_IN_STRINGS |
| 2430 |
#endif |
#endif |
| 2431 |
|
|
| 2432 |
/* Handle the csect auxent of a C_EXT or C_HIDEXT symbol. */ |
/* Handle the csect auxent of a C_EXT, C_AIX_WEAKEXT or C_HIDEXT symbol. */ |
| 2433 |
|
|
| 2434 |
static bfd_boolean |
static bfd_boolean |
| 2435 |
coff_pointerize_aux_hook (bfd *abfd ATTRIBUTE_UNUSED, |
coff_pointerize_aux_hook (bfd *abfd ATTRIBUTE_UNUSED, |
| 2440 |
{ |
{ |
| 2441 |
int class = symbol->u.syment.n_sclass; |
int class = symbol->u.syment.n_sclass; |
| 2442 |
|
|
| 2443 |
if ((class == C_EXT || class == C_HIDEXT) |
if (CSECT_SYM_P (class) |
| 2444 |
&& indaux + 1 == symbol->u.syment.n_numaux) |
&& indaux + 1 == symbol->u.syment.n_numaux) |
| 2445 |
{ |
{ |
| 2446 |
if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD) |
if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD) |
| 2498 |
unsigned int indaux ATTRIBUTE_UNUSED) |
unsigned int indaux ATTRIBUTE_UNUSED) |
| 2499 |
{ |
{ |
| 2500 |
#ifdef RS6000COFF_C |
#ifdef RS6000COFF_C |
| 2501 |
if ((symbol->u.syment.n_sclass == C_EXT |
if (CSECT_SYM_P (symbol->u.syment.n_sclass) |
|
|| symbol->u.syment.n_sclass == C_HIDEXT) |
|
| 2502 |
&& indaux + 1 == symbol->u.syment.n_numaux) |
&& indaux + 1 == symbol->u.syment.n_numaux) |
| 2503 |
{ |
{ |
| 2504 |
/* This is a csect entry. */ |
/* This is a csect entry. */ |
| 3187 |
int target_index; |
int target_index; |
| 3188 |
bfd_size_type amt; |
bfd_size_type amt; |
| 3189 |
|
|
| 3190 |
|
#ifdef COFF_PAGE_SIZE |
| 3191 |
|
/* Clear D_PAGED if section alignment is smaller than |
| 3192 |
|
COFF_PAGE_SIZE. */ |
| 3193 |
|
if (pe_data (abfd)->pe_opthdr.SectionAlignment < COFF_PAGE_SIZE) |
| 3194 |
|
abfd->flags &= ~D_PAGED; |
| 3195 |
|
#endif |
| 3196 |
|
|
| 3197 |
count = 0; |
count = 0; |
| 3198 |
for (current = abfd->sections; current != NULL; current = current->next) |
for (current = abfd->sections; current != NULL; current = current->next) |
| 3199 |
++count; |
++count; |
| 3626 |
bfd_boolean is_reloc_section = FALSE; |
bfd_boolean is_reloc_section = FALSE; |
| 3627 |
|
|
| 3628 |
#ifdef COFF_IMAGE_WITH_PE |
#ifdef COFF_IMAGE_WITH_PE |
| 3629 |
if (strcmp (current->name, ".reloc") == 0) |
if (strcmp (current->name, DOT_RELOC) == 0) |
| 3630 |
{ |
{ |
| 3631 |
is_reloc_section = TRUE; |
is_reloc_section = TRUE; |
| 3632 |
hasrelocs = TRUE; |
hasrelocs = TRUE; |
| 3641 |
#ifdef COFF_LONG_SECTION_NAMES |
#ifdef COFF_LONG_SECTION_NAMES |
| 3642 |
/* Handle long section names as in PE. This must be compatible |
/* Handle long section names as in PE. This must be compatible |
| 3643 |
with the code in coff_write_symbols and _bfd_coff_final_link. */ |
with the code in coff_write_symbols and _bfd_coff_final_link. */ |
| 3644 |
{ |
if (bfd_coff_long_section_names (abfd)) |
| 3645 |
size_t len; |
{ |
| 3646 |
|
size_t len; |
| 3647 |
|
|
| 3648 |
len = strlen (current->name); |
len = strlen (current->name); |
| 3649 |
if (len > SCNNMLEN) |
if (len > SCNNMLEN) |
| 3650 |
{ |
{ |
| 3651 |
memset (section.s_name, 0, SCNNMLEN); |
/* The s_name field is defined to be NUL-padded but need not be |
| 3652 |
sprintf (section.s_name, "/%lu", (unsigned long) string_size); |
NUL-terminated. We use a temporary buffer so that we can still |
| 3653 |
string_size += len + 1; |
sprintf all eight chars without splatting a terminating NUL |
| 3654 |
long_section_names = TRUE; |
over the first byte of the following member (s_paddr). */ |
| 3655 |
} |
char s_name_buf[SCNNMLEN + 1]; |
| 3656 |
} |
|
| 3657 |
|
/* An inherent limitation of the /nnnnnnn notation used to indicate |
| 3658 |
|
the offset of the long name in the string table is that we |
| 3659 |
|
cannot address entries beyone the ten million byte boundary. */ |
| 3660 |
|
if (string_size >= 10000000) |
| 3661 |
|
{ |
| 3662 |
|
bfd_set_error (bfd_error_file_too_big); |
| 3663 |
|
(*_bfd_error_handler) |
| 3664 |
|
(_("%B: section %s: string table overflow at offset %ld"), |
| 3665 |
|
abfd, current->name, string_size); |
| 3666 |
|
return FALSE; |
| 3667 |
|
} |
| 3668 |
|
|
| 3669 |
|
/* snprintf not strictly necessary now we've verified the value |
| 3670 |
|
has less than eight ASCII digits, but never mind. */ |
| 3671 |
|
snprintf (s_name_buf, SCNNMLEN + 1, "/%lu", (unsigned long) string_size); |
| 3672 |
|
/* Then strncpy takes care of any padding for us. */ |
| 3673 |
|
strncpy (section.s_name, s_name_buf, SCNNMLEN); |
| 3674 |
|
string_size += len + 1; |
| 3675 |
|
long_section_names = TRUE; |
| 3676 |
|
} |
| 3677 |
|
} |
| 3678 |
#endif |
#endif |
| 3679 |
|
|
| 3680 |
#ifdef _LIB |
#ifdef _LIB |
| 5398 |
#define coff_SWAP_scnhdr_in coff_swap_scnhdr_in |
#define coff_SWAP_scnhdr_in coff_swap_scnhdr_in |
| 5399 |
#endif |
#endif |
| 5400 |
|
|
| 5401 |
static const bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED = |
static bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED = |
| 5402 |
{ |
{ |
| 5403 |
coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
| 5404 |
coff_SWAP_aux_out, coff_SWAP_sym_out, |
coff_SWAP_aux_out, coff_SWAP_sym_out, |
| 5411 |
#else |
#else |
| 5412 |
FALSE, |
FALSE, |
| 5413 |
#endif |
#endif |
| 5414 |
#ifdef COFF_LONG_SECTION_NAMES |
COFF_DEFAULT_LONG_SECTION_NAMES, |
|
TRUE, |
|
|
#else |
|
|
FALSE, |
|
|
#endif |
|
| 5415 |
COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
| 5416 |
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
| 5417 |
TRUE, |
TRUE, |
| 5438 |
#ifdef TICOFF |
#ifdef TICOFF |
| 5439 |
/* COFF0 differs in file/section header size and relocation entry size. */ |
/* COFF0 differs in file/section header size and relocation entry size. */ |
| 5440 |
|
|
| 5441 |
static const bfd_coff_backend_data ticoff0_swap_table = |
static bfd_coff_backend_data ticoff0_swap_table = |
| 5442 |
{ |
{ |
| 5443 |
coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
| 5444 |
coff_SWAP_aux_out, coff_SWAP_sym_out, |
coff_SWAP_aux_out, coff_SWAP_sym_out, |
| 5451 |
#else |
#else |
| 5452 |
FALSE, |
FALSE, |
| 5453 |
#endif |
#endif |
| 5454 |
#ifdef COFF_LONG_SECTION_NAMES |
COFF_DEFAULT_LONG_SECTION_NAMES, |
|
TRUE, |
|
|
#else |
|
|
FALSE, |
|
|
#endif |
|
| 5455 |
COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
| 5456 |
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
| 5457 |
TRUE, |
TRUE, |
| 5479 |
#ifdef TICOFF |
#ifdef TICOFF |
| 5480 |
/* COFF1 differs in section header size. */ |
/* COFF1 differs in section header size. */ |
| 5481 |
|
|
| 5482 |
static const bfd_coff_backend_data ticoff1_swap_table = |
static bfd_coff_backend_data ticoff1_swap_table = |
| 5483 |
{ |
{ |
| 5484 |
coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in, |
| 5485 |
coff_SWAP_aux_out, coff_SWAP_sym_out, |
coff_SWAP_aux_out, coff_SWAP_sym_out, |
| 5492 |
#else |
#else |
| 5493 |
FALSE, |
FALSE, |
| 5494 |
#endif |
#endif |
| 5495 |
#ifdef COFF_LONG_SECTION_NAMES |
COFF_DEFAULT_LONG_SECTION_NAMES, |
|
TRUE, |
|
|
#else |
|
|
FALSE, |
|
|
#endif |
|
| 5496 |
COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
COFF_DEFAULT_SECTION_ALIGNMENT_POWER, |
| 5497 |
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
#ifdef COFF_FORCE_SYMBOLS_IN_STRINGS |
| 5498 |
TRUE, |
TRUE, |
| 5612 |
_bfd_generic_section_already_linked |
_bfd_generic_section_already_linked |
| 5613 |
#endif |
#endif |
| 5614 |
|
|
| 5615 |
|
#ifndef coff_bfd_define_common_symbol |
| 5616 |
|
#define coff_bfd_define_common_symbol bfd_generic_define_common_symbol |
| 5617 |
|
#endif |
| 5618 |
|
|
| 5619 |
#define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \ |
#define CREATE_BIG_COFF_TARGET_VEC(VAR, NAME, EXTRA_O_FLAGS, EXTRA_S_FLAGS, UNDER, ALTERNATIVE, SWAP_TABLE) \ |
| 5620 |
const bfd_target VAR = \ |
const bfd_target VAR = \ |
| 5621 |
{ \ |
{ \ |