BFD: Catch & report unhandled PE section flags.

LD: Catch BFD errors whilst loading symbols and do not produce an executable.
This commit is contained in:
Nick Clifton 2001-02-27 01:38:06 +00:00
parent fa7cd6d20a
commit 1276aefac0
7 changed files with 790 additions and 643 deletions

View File

@ -1,3 +1,15 @@
2001-02-26 Nick Clifton <nickc@redhat.com>
* coffcode.h (styp_to_sec_flags) [COFF_WITH_PE version]: Tidy
up, replacing multiple if statements with a switch.
(handle_COMDAT): New function.
2001-02-26 H.J. Lu <hjl@gnu.org>
* coffcode.h (styp_to_sec_flags) [COFF_WITH_PE version]: Issue
a warning for section flags we do not handle instead of
aborting.
2001-02-26 Andreas Jaeger <aj@suse.de> 2001-02-26 Andreas Jaeger <aj@suse.de>
* elf64-x86-64.c (x86_64_elf_howto_table): Fix order of entries. * elf64-x86-64.c (x86_64_elf_howto_table): Fix order of entries.

View File

@ -339,6 +339,9 @@ static long coff_canonicalize_reloc
#ifndef coff_mkobject_hook #ifndef coff_mkobject_hook
static PTR coff_mkobject_hook PARAMS ((bfd *, PTR, PTR)); static PTR coff_mkobject_hook PARAMS ((bfd *, PTR, PTR));
#endif #endif
#ifdef COFF_WITH_PE
static flagword handle_COMDAT PARAMS ((bfd *, flagword, PTR, const char *, asection *));
#endif
/* void warning(); */ /* void warning(); */
@ -698,6 +701,261 @@ styp_to_sec_flags (abfd, hdr, name, section)
#else /* COFF_WITH_PE */ #else /* COFF_WITH_PE */
static flagword
handle_COMDAT (abfd, sec_flags, hdr, name, section)
bfd * abfd;
flagword sec_flags;
PTR hdr;
const char *name;
asection *section;
{
struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
bfd_byte *esymstart, *esym, *esymend;
int seen_state = 0;
char *target_name = NULL;
sec_flags |= SEC_LINK_ONCE;
/* Unfortunately, the PE format stores essential information in
the symbol table, of all places. We need to extract that
information now, so that objdump and the linker will know how
to handle the section without worrying about the symbols. We
can't call slurp_symtab, because the linker doesn't want the
swapped symbols. */
/* COMDAT sections are special. The first symbol is the section
symbol, which tells what kind of COMDAT section it is. The
second symbol is the "comdat symbol" - the one with the
unique name. GNU uses the section symbol for the unique
name; MS uses ".text" for every comdat section. Sigh. - DJ */
/* This is not mirrored in sec_to_styp_flags(), but there
doesn't seem to be a need to, either, and it would at best be
rather messy. */
if (! _bfd_coff_get_external_symbols (abfd))
return sec_flags;
esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
while (esym < esymend)
{
struct internal_syment isym;
char buf[SYMNMLEN + 1];
const char *symname;
bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &isym);
if (sizeof (internal_s->s_name) > SYMNMLEN)
{
/* This case implies that the matching
symbol name will be in the string table. */
abort ();
}
if (isym.n_scnum == section->target_index)
{
/* According to the MSVC documentation, the first
TWO entries with the section # are both of
interest to us. The first one is the "section
symbol" (section name). The second is the comdat
symbol name. Here, we've found the first
qualifying entry; we distinguish it from the
second with a state flag.
In the case of gas-generated (at least until that
is fixed) .o files, it isn't necessarily the
second one. It may be some other later symbol.
Since gas also doesn't follow MS conventions and
emits the section similar to .text$<name>, where
<something> is the name we're looking for, we
distinguish the two as follows:
If the section name is simply a section name (no
$) we presume it's MS-generated, and look at
precisely the second symbol for the comdat name.
If the section name has a $, we assume it's
gas-generated, and look for <something> (whatever
follows the $) as the comdat symbol. */
/* All 3 branches use this */
symname = _bfd_coff_internal_syment_name (abfd, &isym, buf);
if (symname == NULL)
abort ();
switch (seen_state)
{
case 0:
{
/* The first time we've seen the symbol. */
union internal_auxent aux;
seen_state = 1;
/* If it isn't the stuff we're expecting, die;
The MS documentation is vague, but it
appears that the second entry serves BOTH
as the comdat symbol and the defining
symbol record (either C_STAT or C_EXT,
possibly with an aux entry with debug
information if it's a function.) It
appears the only way to find the second one
is to count. (On Intel, they appear to be
adjacent, but on Alpha, they have been
found separated.)
Here, we think we've found the first one,
but there's some checking we can do to be
sure. */
if (! (isym.n_sclass == C_STAT
&& isym.n_type == T_NULL
&& isym.n_value == 0))
abort ();
/* FIXME LATER: MSVC generates section names
like .text for comdats. Gas generates
names like .text$foo__Fv (in the case of a
function). See comment above for more. */
if (strcmp (name, symname) != 0)
abort ();
/* This is the section symbol. */
bfd_coff_swap_aux_in (abfd, (PTR) (esym + bfd_coff_symesz (abfd)),
isym.n_type, isym.n_sclass,
0, isym.n_numaux, (PTR) &aux);
target_name = strchr (name, '$');
if (target_name != NULL)
{
/* Gas mode. */
seen_state = 2;
/* Skip the `$'. */
target_name += 1;
}
/* FIXME: Microsoft uses NODUPLICATES and
ASSOCIATIVE, but gnu uses ANY and
SAME_SIZE. Unfortunately, gnu doesn't do
the comdat symbols right. So, until we can
fix it to do the right thing, we are
temporarily disabling comdats for the MS
types (they're used in DLLs and C++, but we
don't support *their* C++ libraries anyway
- DJ. */
/* Cygwin does not follow the MS style, and
uses ANY and SAME_SIZE where NODUPLICATES
and ASSOCIATIVE should be used. For
Interix, we just do the right thing up
front. */
switch (aux.x_scn.x_comdat)
{
case IMAGE_COMDAT_SELECT_NODUPLICATES:
#ifdef STRICT_PE_FORMAT
sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
#else
sec_flags &= ~SEC_LINK_ONCE;
#endif
break;
case IMAGE_COMDAT_SELECT_ANY:
sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
break;
case IMAGE_COMDAT_SELECT_SAME_SIZE:
sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
break;
case IMAGE_COMDAT_SELECT_EXACT_MATCH:
/* Not yet fully implemented ??? */
sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
break;
/* debug$S gets this case; other
implications ??? */
/* There may be no symbol... we'll search
the whole table... Is this the right
place to play this game? Or should we do
it when reading it in. */
case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
#ifdef STRICT_PE_FORMAT
/* FIXME: This is not currently implemented. */
sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
#else
sec_flags &= ~SEC_LINK_ONCE;
#endif
break;
default: /* 0 means "no symbol" */
/* debug$F gets this case; other
implications ??? */
sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
break;
}
}
break;
case 2:
/* Gas mode: the first matching on partial name. */
#ifndef TARGET_UNDERSCORE
#define TARGET_UNDERSCORE 0
#endif
/* Is this the name we're looking for? */
if (strcmp (target_name,
symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
{
/* Not the name we're looking for */
esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd);
continue;
}
/* Fall through. */
case 1:
/* MSVC mode: the lexically second symbol (or
drop through from the above). */
{
char *newname;
/* This must the the second symbol with the
section #. It is the actual symbol name.
Intel puts the two adjacent, but Alpha (at
least) spreads them out. */
section->comdat =
bfd_alloc (abfd, sizeof (struct bfd_comdat_info));
if (section->comdat == NULL)
abort ();
section->comdat->symbol =
(esym - esymstart) / bfd_coff_symesz (abfd);
newname = bfd_alloc (abfd, strlen (symname) + 1);
if (newname == NULL)
abort ();
strcpy (newname, symname);
section->comdat->name = newname;
}
goto breakloop;
}
}
esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd);
}
breakloop:
return sec_flags;
}
/* The PE version; see above for the general comments. /* The PE version; see above for the general comments.
Since to set the SEC_LINK_ONCE and associated flags, we have to Since to set the SEC_LINK_ONCE and associated flags, we have to
@ -709,318 +967,116 @@ styp_to_sec_flags (abfd, hdr, name, section)
static flagword static flagword
styp_to_sec_flags (abfd, hdr, name, section) styp_to_sec_flags (abfd, hdr, name, section)
bfd *abfd ATTRIBUTE_UNUSED; bfd *abfd;
PTR hdr; PTR hdr;
const char *name; const char *name;
asection *section; asection *section;
{ {
struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
long styp_flags = internal_s->s_flags; long styp_flags = internal_s->s_flags;
flagword sec_flags = 0; flagword sec_flags;
if (styp_flags & STYP_DSECT) /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */
abort (); /* Don't know what to do */ sec_flags = SEC_READONLY;
#ifdef SEC_NEVER_LOAD
if (styp_flags & STYP_NOLOAD) /* Process each flag bit in styp_flags in turn. */
sec_flags |= SEC_NEVER_LOAD; while (styp_flags)
#endif
if (styp_flags & STYP_GROUP)
abort (); /* Don't know what to do */
/* skip IMAGE_SCN_TYPE_NO_PAD */
if (styp_flags & STYP_COPY)
abort (); /* Don't know what to do */
if (styp_flags & IMAGE_SCN_CNT_CODE)
sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
if (styp_flags & IMAGE_SCN_CNT_INITIALIZED_DATA)
sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
if (styp_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
sec_flags |= SEC_ALLOC;
if (styp_flags & IMAGE_SCN_LNK_OTHER)
abort (); /* Don't know what to do */
if (styp_flags & IMAGE_SCN_LNK_INFO)
{ {
/* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is long flag = styp_flags & - styp_flags;
defined. coff_compute_section_file_positions uses char * unhandled = NULL;
COFF_PAGE_SIZE to ensure that the low order bits of the
section VMA and the file offset match. If we don't know styp_flags &= ~ flag;
COFF_PAGE_SIZE, we can't ensure the correct correspondence,
and demand page loading of the file will fail. */
#ifdef COFF_PAGE_SIZE
sec_flags |= SEC_DEBUGGING;
#endif
}
if (styp_flags & STYP_OVER)
abort (); /* Don't know what to do */
if (styp_flags & IMAGE_SCN_LNK_REMOVE)
sec_flags |= SEC_EXCLUDE;
if (styp_flags & IMAGE_SCN_MEM_SHARED) /* We infer from the distinct read/write/execute bits the settings
sec_flags |= SEC_SHARED; of some of the bfd flags; the actual values, should we need them,
/* COMDAT: see below */ are also in pei_section_data (abfd, section)->pe_flags. */
if (styp_flags & IMAGE_SCN_MEM_DISCARDABLE)
sec_flags |= SEC_DEBUGGING;
if (styp_flags & IMAGE_SCN_MEM_NOT_CACHED)
abort ();/* Don't know what to do */
if (styp_flags & IMAGE_SCN_MEM_NOT_PAGED)
abort (); /* Don't know what to do */
/* We infer from the distinct read/write/execute bits the settings switch (flag)
of some of the bfd flags; the actual values, should we need them,
are also in pei_section_data (abfd, section)->pe_flags. */
if (styp_flags & IMAGE_SCN_MEM_EXECUTE)
sec_flags |= SEC_CODE; /* Probably redundant */
/* IMAGE_SCN_MEM_READ is simply ignored, assuming it always to be true. */
if ((styp_flags & IMAGE_SCN_MEM_WRITE) == 0)
sec_flags |= SEC_READONLY;
/* COMDAT gets very special treatment. */
if (styp_flags & IMAGE_SCN_LNK_COMDAT)
{
sec_flags |= SEC_LINK_ONCE;
/* Unfortunately, the PE format stores essential information in
the symbol table, of all places. We need to extract that
information now, so that objdump and the linker will know how
to handle the section without worrying about the symbols. We
can't call slurp_symtab, because the linker doesn't want the
swapped symbols. */
/* COMDAT sections are special. The first symbol is the section
symbol, which tells what kind of COMDAT section it is. The
second symbol is the "comdat symbol" - the one with the
unique name. GNU uses the section symbol for the unique
name; MS uses ".text" for every comdat section. Sigh. - DJ */
/* This is not mirrored in sec_to_styp_flags(), but there
doesn't seem to be a need to, either, and it would at best be
rather messy. */
if (_bfd_coff_get_external_symbols (abfd))
{ {
bfd_byte *esymstart, *esym, *esymend; case STYP_DSECT:
int seen_state = 0; unhandled = "STYP_DSECT";
char *target_name = NULL; break;
case STYP_GROUP:
esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd); unhandled = "STYP_GROUP";
esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd); break;
case STYP_COPY:
while (esym < esymend) unhandled = "STYP_COPY";
{ break;
struct internal_syment isym; case STYP_OVER:
char buf[SYMNMLEN + 1]; unhandled = "STYP_OVER";
const char *symname; break;
#ifdef SEC_NEVER_LOAD
bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &isym); case STYP_NOLOAD:
sec_flags |= SEC_NEVER_LOAD;
if (sizeof (internal_s->s_name) > SYMNMLEN) break;
{ #endif
/* This case implies that the matching symbol name case IMAGE_SCN_MEM_READ:
will be in the string table. */ /* Ignored, assume it always to be true. */
abort (); break;
} case IMAGE_SCN_TYPE_NO_PAD:
/* Skip. */
if (isym.n_scnum == section->target_index) break;
{ case IMAGE_SCN_LNK_OTHER:
/* According to the MSVC documentation, the first unhandled = "IMAGE_SCN_LNK_OTHER";
TWO entries with the section # are both of break;
interest to us. The first one is the "section case IMAGE_SCN_MEM_NOT_CACHED:
symbol" (section name). The second is the comdat unhandled = "IMAGE_SCN_MEM_NOT_CACHED";
symbol name. Here, we've found the first break;
qualifying entry; we distinguish it from the case IMAGE_SCN_MEM_NOT_PAGED:
second with a state flag. unhandled = "IMAGE_SCN_MEM_NOT_PAGED";
break;
In the case of gas-generated (at least until that case IMAGE_SCN_MEM_EXECUTE:
is fixed) .o files, it isn't necessarily the sec_flags |= SEC_CODE;
second one. It may be some other later symbol. break;
case IMAGE_SCN_MEM_WRITE:
Since gas also doesn't follow MS conventions and sec_flags &= ~ SEC_READONLY;
emits the section similar to .text$<name>, where break;
<something> is the name we're looking for, we case IMAGE_SCN_MEM_DISCARDABLE:
distinguish the two as follows: sec_flags |= SEC_DEBUGGING;
break;
If the section name is simply a section name (no case IMAGE_SCN_MEM_SHARED:
$) we presume it's MS-generated, and look at sec_flags |= SEC_SHARED;
precisely the second symbol for the comdat name. break;
If the section name has a $, we assume it's case IMAGE_SCN_LNK_REMOVE:
gas-generated, and look for <something> (whatever sec_flags |= SEC_EXCLUDE;
follows the $) as the comdat symbol. */ break;
case IMAGE_SCN_CNT_CODE:
/* All 3 branches use this */ sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD;
symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); break;
case IMAGE_SCN_CNT_INITIALIZED_DATA:
if (symname == NULL) sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD;
abort (); break;
case IMAGE_SCN_CNT_UNINITIALIZED_DATA:
switch (seen_state) sec_flags |= SEC_ALLOC;
{ break;
case 0: case IMAGE_SCN_LNK_INFO:
{ /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
/* The first time we've seen the symbol. */ defined. coff_compute_section_file_positions uses
union internal_auxent aux; COFF_PAGE_SIZE to ensure that the low order bits of the
section VMA and the file offset match. If we don't know
seen_state = 1; COFF_PAGE_SIZE, we can't ensure the correct correspondence,
and demand page loading of the file will fail. */
/* If it isn't the stuff we're expecting, die; #ifdef COFF_PAGE_SIZE
The MS documentation is vague, but it sec_flags |= SEC_DEBUGGING;
appears that the second entry serves BOTH
as the comdat symbol and the defining
symbol record (either C_STAT or C_EXT,
possibly with an aux entry with debug
information if it's a function.) It
appears the only way to find the second one
is to count. (On Intel, they appear to be
adjacent, but on Alpha, they have been
found separated.)
Here, we think we've found the first one,
but there's some checking we can do to be
sure. */
if (! (isym.n_sclass == C_STAT
&& isym.n_type == T_NULL
&& isym.n_value == 0))
abort ();
/* FIXME LATER: MSVC generates section names
like .text for comdats. Gas generates
names like .text$foo__Fv (in the case of a
function). See comment above for more. */
if (strcmp (name, symname) != 0)
abort ();
/* This is the section symbol. */
bfd_coff_swap_aux_in (abfd, (PTR) (esym + bfd_coff_symesz (abfd)),
isym.n_type, isym.n_sclass,
0, isym.n_numaux, (PTR) &aux);
target_name = strchr (name, '$');
if (target_name != NULL)
{
/* Gas mode. */
seen_state = 2;
/* Skip the `$'. */
target_name += 1;
}
/* FIXME: Microsoft uses NODUPLICATES and
ASSOCIATIVE, but gnu uses ANY and
SAME_SIZE. Unfortunately, gnu doesn't do
the comdat symbols right. So, until we can
fix it to do the right thing, we are
temporarily disabling comdats for the MS
types (they're used in DLLs and C++, but we
don't support *their* C++ libraries anyway
- DJ. */
/* Cygwin does not follow the MS style, and
uses ANY and SAME_SIZE where NODUPLICATES
and ASSOCIATIVE should be used. For
Interix, we just do the right thing up
front. */
switch (aux.x_scn.x_comdat)
{
case IMAGE_COMDAT_SELECT_NODUPLICATES:
#ifdef STRICT_PE_FORMAT
sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
#else
sec_flags &= ~SEC_LINK_ONCE;
#endif #endif
break; break;
case IMAGE_SCN_LNK_COMDAT:
case IMAGE_COMDAT_SELECT_ANY: /* COMDAT gets very special treatment. */
sec_flags |= SEC_LINK_DUPLICATES_DISCARD; sec_flags = handle_COMDAT (abfd, sec_flags, hdr, name, section);
break; break;
default:
case IMAGE_COMDAT_SELECT_SAME_SIZE: /* Silently ignore for now. */
sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; break;
break;
case IMAGE_COMDAT_SELECT_EXACT_MATCH:
/* Not yet fully implemented ??? */
sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
break;
/* debug$S gets this case; other
implications ??? */
/* There may be no symbol... we'll search
the whole table... Is this the right
place to play this game? Or should we do
it when reading it in. */
case IMAGE_COMDAT_SELECT_ASSOCIATIVE:
#ifdef STRICT_PE_FORMAT
/* FIXME: This is not currently implemented. */
sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
#else
sec_flags &= ~SEC_LINK_ONCE;
#endif
break;
default: /* 0 means "no symbol" */
/* debug$F gets this case; other
implications ??? */
sec_flags |= SEC_LINK_DUPLICATES_DISCARD;
break;
}
}
break;
case 2:
/* Gas mode: the first matching on partial name. */
#ifndef TARGET_UNDERSCORE
#define TARGET_UNDERSCORE 0
#endif
/* Is this the name we're looking for? */
if (strcmp (target_name,
symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0)
{
/* Not the name we're looking for */
esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd);
continue;
}
/* Fall through. */
case 1:
/* MSVC mode: the lexically second symbol (or
drop through from the above). */
{
char *newname;
/* This must the the second symbol with the
section #. It is the actual symbol name.
Intel puts the two adjacent, but Alpha (at
least) spreads them out. */
section->comdat =
bfd_alloc (abfd, sizeof (struct bfd_comdat_info));
if (section->comdat == NULL)
abort ();
section->comdat->symbol =
(esym - esymstart) / bfd_coff_symesz (abfd);
newname = bfd_alloc (abfd, strlen (symname) + 1);
if (newname == NULL)
abort ();
strcpy (newname, symname);
section->comdat->name = newname;
}
goto breakloop;
}
}
esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd);
}
breakloop:
/* SunOS requires a statement after any label. */
;
} }
/* If the section flag was not handled, report it here. This will allow
users of the BFD library to report a problem but continue executing.
Tools which need to be aware of these problems (such as the linker)
can override the default bfd_error_handler to intercept these reports. */
if (unhandled != NULL)
(*_bfd_error_handler)
(_("%s (%s): Section flag %s (0x%x) ignored"),
bfd_get_filename (abfd), name, unhandled, flag);
} }
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) #if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)

543
bfd/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2001-02-18 15:14-0800\n" "POT-Creation-Date: 2001-02-26 17:19-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -326,37 +326,42 @@ msgstr ""
msgid "Warning: Clearing the interworking flag of %s due to outside request" msgid "Warning: Clearing the interworking flag of %s due to outside request"
msgstr "" msgstr ""
#: coffcode.h:2136 #: coffcode.h:1080
#, c-format
msgid "%s (%s): Section flag %s (0x%x) ignored"
msgstr ""
#: coffcode.h:2194
#, c-format #, c-format
msgid "Unrecognized TI COFF target id '0x%x'" msgid "Unrecognized TI COFF target id '0x%x'"
msgstr "" msgstr ""
#: coffcode.h:4194 #: coffcode.h:4252
#, c-format #, c-format
msgid "%s: warning: illegal symbol index %ld in line numbers" msgid "%s: warning: illegal symbol index %ld in line numbers"
msgstr "" msgstr ""
#: coffcode.h:4208 #: coffcode.h:4266
#, c-format #, c-format
msgid "%s: warning: duplicate line number information for `%s'" msgid "%s: warning: duplicate line number information for `%s'"
msgstr "" msgstr ""
#: coffcode.h:4568 #: coffcode.h:4626
#, c-format #, c-format
msgid "%s: Unrecognized storage class %d for %s symbol `%s'" msgid "%s: Unrecognized storage class %d for %s symbol `%s'"
msgstr "" msgstr ""
#: coffcode.h:4699 #: coffcode.h:4757
#, c-format #, c-format
msgid "warning: %s: local symbol `%s' has no section" msgid "warning: %s: local symbol `%s' has no section"
msgstr "" msgstr ""
#: coff-tic54x.c:376 coffcode.h:4810 #: coff-tic54x.c:376 coffcode.h:4868
#, c-format #, c-format
msgid "%s: warning: illegal symbol index %ld in relocs" msgid "%s: warning: illegal symbol index %ld in relocs"
msgstr "" msgstr ""
#: coffcode.h:4848 #: coffcode.h:4906
#, c-format #, c-format
msgid "%s: illegal relocation type %d at address 0x%lx" msgid "%s: illegal relocation type %d at address 0x%lx"
msgstr "" msgstr ""
@ -890,7 +895,7 @@ msgstr ""
msgid "%s: ABI mismatch: linking %s module with previous %s modules" msgid "%s: ABI mismatch: linking %s module with previous %s modules"
msgstr "" msgstr ""
#: elf32-mips.c:2673 elf32-ppc.c:1477 elf64-sparc.c:2991 #: elf32-mips.c:2673 elf32-ppc.c:1477 elf64-sparc.c:2998
#, c-format #, c-format
msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)" msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
msgstr "" msgstr ""
@ -1078,12 +1083,12 @@ msgstr ""
msgid "%s: probably compiled without -fPIC?" msgid "%s: probably compiled without -fPIC?"
msgstr "" msgstr ""
#: elf32-sparc.c:1962 #: elf32-sparc.c:1969
#, c-format #, c-format
msgid "%s: compiled for a 64 bit system and target is 32 bit" msgid "%s: compiled for a 64 bit system and target is 32 bit"
msgstr "" msgstr ""
#: elf32-sparc.c:1976 #: elf32-sparc.c:1983
#, c-format #, c-format
msgid "%s: linking little endian files with big endian files" msgid "%s: linking little endian files with big endian files"
msgstr "" msgstr ""
@ -1194,7 +1199,7 @@ msgstr ""
msgid "Symbol `%s' has differing types: REGISTER in %s, %s in %s" msgid "Symbol `%s' has differing types: REGISTER in %s, %s in %s"
msgstr "" msgstr ""
#: elf64-sparc.c:2972 #: elf64-sparc.c:2979
#, c-format #, c-format
msgid "%s: linking UltraSPARC specific with HAL specific code" msgid "%s: linking UltraSPARC specific with HAL specific code"
msgstr "" msgstr ""

View File

@ -1,3 +1,10 @@
2001-02-26 H.J. Lu <hjl@gnu.org>
* ldlang.c (open_input_bfds): Set the bfd error handler so
that problems can be caught whilst loading symbols.
(record_bfd_errors): New function: Report BFD errors and mark
the executable output as being invalid.
2001-02-22 Timothy Wall <twall@cygnus.com> 2001-02-22 Timothy Wall <twall@cygnus.com>
* configure.host: Add configuration for ia64-*-aix*. * configure.host: Add configuration for ia64-*-aix*.

View File

@ -127,6 +127,7 @@ static bfd_vma size_input_section
fill_type, bfd_vma, boolean)); fill_type, bfd_vma, boolean));
static void lang_finish PARAMS ((void)); static void lang_finish PARAMS ((void));
static void ignore_bfd_errors PARAMS ((const char *, ...)); static void ignore_bfd_errors PARAMS ((const char *, ...));
static void record_bfd_errors PARAMS ((const char *, ...));
static void lang_check PARAMS ((void)); static void lang_check PARAMS ((void));
static void lang_common PARAMS ((void)); static void lang_common PARAMS ((void));
static boolean lang_one_common PARAMS ((struct bfd_link_hash_entry *, PTR)); static boolean lang_one_common PARAMS ((struct bfd_link_hash_entry *, PTR));
@ -1894,6 +1895,7 @@ open_input_bfds (s, force)
if (s->input_statement.real) if (s->input_statement.real)
{ {
lang_statement_list_type add; lang_statement_list_type add;
bfd_error_handler_type pfn;
s->input_statement.target = current_target; s->input_statement.target = current_target;
@ -1908,10 +1910,17 @@ open_input_bfds (s, force)
bfd_archive)) bfd_archive))
s->input_statement.loaded = false; s->input_statement.loaded = false;
lang_list_init (&add); lang_list_init (& add);
/* We need to know if an error occurs whilst loading the
symbols, since this means that a valid executable can
not be produced. */
pfn = bfd_set_error_handler (record_bfd_errors);
load_symbols (&s->input_statement, &add); load_symbols (&s->input_statement, &add);
bfd_set_error_handler (pfn);
if (add.head != NULL) if (add.head != NULL)
{ {
*add.tail = s->next; *add.tail = s->next;
@ -3435,6 +3444,53 @@ lang_finish ()
} }
} }
/* This is the routine to handle BFD error messages. */
#ifdef ANSI_PROTOTYPES
static void
record_bfd_errors (const char *s, ...)
{
va_list p;
einfo ("%P: ");
va_start (p, s);
vfprintf (stderr, s, p);
va_end (p);
fprintf (stderr, "\n");
einfo ("%X");
}
#else /* ! defined (ANSI_PROTOTYPES) */
static void
record_bfd_errors (va_alist)
va_dcl
{
va_list p;
const char *s;
einfo ("%P: ");
va_start (p);
s = va_arg (p, const char *);
vfprintf (stderr, s, p);
va_end (p);
fprintf (stderr, "\n");
einfo ("%X");
}
#endif /* ! defined (ANSI_PROTOTYPES) */
/* This is a small function used when we want to ignore errors from /* This is a small function used when we want to ignore errors from
BFD. */ BFD. */

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2001-02-18 11:47-0800\n" "POT-Creation-Date: 2001-02-26 16:28-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -250,7 +250,7 @@ msgstr ""
msgid "Errors encountered processing file %s for interworking" msgid "Errors encountered processing file %s for interworking"
msgstr "" msgstr ""
#: emultempl/pe.em:1094 ldlang.c:1994 ldlang.c:4363 ldlang.c:4396 #: emultempl/pe.em:1094 ldlang.c:2003 ldlang.c:4419 ldlang.c:4452
#: ldmain.c:1016 #: ldmain.c:1016
msgid "%P%F: bfd_link_hash_lookup failed: %E\n" msgid "%P%F: bfd_link_hash_lookup failed: %E\n"
msgstr "" msgstr ""
@ -427,230 +427,230 @@ msgstr ""
msgid "%F%P: cannot open %s: %E\n" msgid "%F%P: cannot open %s: %E\n"
msgstr "" msgstr ""
#: ldfile.c:250 #: ldfile.c:259
msgid "%F%P: cannot find %s\n" msgid "%F%P: cannot find %s\n"
msgstr "" msgstr ""
#: ldfile.c:269 ldfile.c:285 #: ldfile.c:278 ldfile.c:294
#, c-format #, c-format
msgid "cannot find script file %s\n" msgid "cannot find script file %s\n"
msgstr "" msgstr ""
#: ldfile.c:271 ldfile.c:287 #: ldfile.c:280 ldfile.c:296
#, c-format #, c-format
msgid "opened script file %s\n" msgid "opened script file %s\n"
msgstr "" msgstr ""
#: ldfile.c:336 #: ldfile.c:345
msgid "%P%F: cannot open linker script file %s: %E\n" msgid "%P%F: cannot open linker script file %s: %E\n"
msgstr "" msgstr ""
#: ldfile.c:373 #: ldfile.c:382
msgid "%P%F: unknown architecture: %s\n" msgid "%P%F: unknown architecture: %s\n"
msgstr "" msgstr ""
#: ldfile.c:389 #: ldfile.c:398
msgid "%P%F: target architecture respecified\n" msgid "%P%F: target architecture respecified\n"
msgstr "" msgstr ""
#: ldfile.c:444 #: ldfile.c:453
msgid "%P%F: cannot represent machine `%s'\n" msgid "%P%F: cannot represent machine `%s'\n"
msgstr "" msgstr ""
#: ldlang.c:749 #: ldlang.c:750
msgid "" msgid ""
"\n" "\n"
"Memory Configuration\n" "Memory Configuration\n"
"\n" "\n"
msgstr "" msgstr ""
#: ldlang.c:751 #: ldlang.c:752
msgid "Name" msgid "Name"
msgstr "" msgstr ""
#: ldlang.c:751 #: ldlang.c:752
msgid "Origin" msgid "Origin"
msgstr "" msgstr ""
#: ldlang.c:751 #: ldlang.c:752
msgid "Length" msgid "Length"
msgstr "" msgstr ""
#: ldlang.c:751 #: ldlang.c:752
msgid "Attributes" msgid "Attributes"
msgstr "" msgstr ""
#: ldlang.c:793 #: ldlang.c:794
msgid "" msgid ""
"\n" "\n"
"Linker script and memory map\n" "Linker script and memory map\n"
"\n" "\n"
msgstr "" msgstr ""
#: ldlang.c:810 #: ldlang.c:811
msgid "%P%F: Illegal use of `%s' section" msgid "%P%F: Illegal use of `%s' section"
msgstr "" msgstr ""
#: ldlang.c:820 #: ldlang.c:821
msgid "%P%F: output format %s cannot represent section called %s\n" msgid "%P%F: output format %s cannot represent section called %s\n"
msgstr "" msgstr ""
#: ldlang.c:982 #: ldlang.c:983
msgid "%P: %B: warning: ignoring duplicate section `%s'\n" msgid "%P: %B: warning: ignoring duplicate section `%s'\n"
msgstr "" msgstr ""
#: ldlang.c:985 #: ldlang.c:986
msgid "%P: %B: warning: ignoring duplicate `%s' section symbol `%s'\n" msgid "%P: %B: warning: ignoring duplicate `%s' section symbol `%s'\n"
msgstr "" msgstr ""
#: ldlang.c:999 #: ldlang.c:1000
msgid "%P: %B: warning: duplicate section `%s' has different size\n" msgid "%P: %B: warning: duplicate section `%s' has different size\n"
msgstr "" msgstr ""
#: ldlang.c:1050 #: ldlang.c:1051
msgid "%P%F: Failed to create hash table\n" msgid "%P%F: Failed to create hash table\n"
msgstr "" msgstr ""
#: ldlang.c:1440 #: ldlang.c:1441
msgid "%B: file not recognized: %E\n" msgid "%B: file not recognized: %E\n"
msgstr "" msgstr ""
#: ldlang.c:1441 #: ldlang.c:1442
msgid "%B: matching formats:" msgid "%B: matching formats:"
msgstr "" msgstr ""
#: ldlang.c:1448 #: ldlang.c:1449
msgid "%F%B: file not recognized: %E\n" msgid "%F%B: file not recognized: %E\n"
msgstr "" msgstr ""
#: ldlang.c:1501 #: ldlang.c:1502
msgid "%F%B: object %B in archive is not object\n" msgid "%F%B: object %B in archive is not object\n"
msgstr "" msgstr ""
#: ldlang.c:1507 ldlang.c:1519 #: ldlang.c:1508 ldlang.c:1520
msgid "%F%B: could not read symbols: %E\n" msgid "%F%B: could not read symbols: %E\n"
msgstr "" msgstr ""
#: ldlang.c:1779 #: ldlang.c:1780
msgid "" msgid ""
"%P: warning: could not find any targets that match endianness requirement\n" "%P: warning: could not find any targets that match endianness requirement\n"
msgstr "" msgstr ""
#: ldlang.c:1792 #: ldlang.c:1793
msgid "%P%F: target %s not found\n" msgid "%P%F: target %s not found\n"
msgstr "" msgstr ""
#: ldlang.c:1794 #: ldlang.c:1795
msgid "%P%F: cannot open output file %s: %E\n" msgid "%P%F: cannot open output file %s: %E\n"
msgstr "" msgstr ""
#: ldlang.c:1804 #: ldlang.c:1805
msgid "%P%F:%s: can not make object file: %E\n" msgid "%P%F:%s: can not make object file: %E\n"
msgstr "" msgstr ""
#: ldlang.c:1808 #: ldlang.c:1809
msgid "%P%F:%s: can not set architecture: %E\n" msgid "%P%F:%s: can not set architecture: %E\n"
msgstr "" msgstr ""
#: ldlang.c:1812 #: ldlang.c:1813
msgid "%P%F: can not create link hash table: %E\n" msgid "%P%F: can not create link hash table: %E\n"
msgstr "" msgstr ""
#: ldlang.c:2117 #: ldlang.c:2126
msgid " load address 0x%V" msgid " load address 0x%V"
msgstr "" msgstr ""
#: ldlang.c:2247 #: ldlang.c:2256
msgid "%W (size before relaxing)\n" msgid "%W (size before relaxing)\n"
msgstr "" msgstr ""
#: ldlang.c:2329 #: ldlang.c:2338
#, c-format #, c-format
msgid "Address of section %s set to " msgid "Address of section %s set to "
msgstr "" msgstr ""
#: ldlang.c:2478 #: ldlang.c:2487
#, c-format #, c-format
msgid "Fail with %d\n" msgid "Fail with %d\n"
msgstr "" msgstr ""
#: ldlang.c:2716 #: ldlang.c:2725
msgid "%X%P: section %s [%V -> %V] overlaps section %s [%V -> %V]\n" msgid "%X%P: section %s [%V -> %V] overlaps section %s [%V -> %V]\n"
msgstr "" msgstr ""
#: ldlang.c:2750 #: ldlang.c:2759
msgid "%X%P: address 0x%v of %B section %s is not within region %s\n" msgid "%X%P: address 0x%v of %B section %s is not within region %s\n"
msgstr "" msgstr ""
#: ldlang.c:2758 #: ldlang.c:2767
msgid "%X%P: region %s is full (%B section %s)\n" msgid "%X%P: region %s is full (%B section %s)\n"
msgstr "" msgstr ""
#: ldlang.c:2807 #: ldlang.c:2816
msgid "%P%X: Internal error on COFF shared library section %s\n" msgid "%P%X: Internal error on COFF shared library section %s\n"
msgstr "" msgstr ""
#: ldlang.c:2848 #: ldlang.c:2857
msgid "%P: warning: no memory region specified for section `%s'\n" msgid "%P: warning: no memory region specified for section `%s'\n"
msgstr "" msgstr ""
#: ldlang.c:2861 #: ldlang.c:2870
msgid "%P: warning: changing start of section %s by %u bytes\n" msgid "%P: warning: changing start of section %s by %u bytes\n"
msgstr "" msgstr ""
#: ldlang.c:2875 #: ldlang.c:2884
msgid "%F%S: non constant address expression for section %s\n" msgid "%F%S: non constant address expression for section %s\n"
msgstr "" msgstr ""
#: ldlang.c:2940 #: ldlang.c:2949
msgid "%X%P: use an absolute load address or a load memory region, not both\n" msgid "%X%P: use an absolute load address or a load memory region, not both\n"
msgstr "" msgstr ""
#: ldlang.c:3056 #: ldlang.c:3065
msgid "%P%F: can't relax section: %E\n" msgid "%P%F: can't relax section: %E\n"
msgstr "" msgstr ""
#: ldlang.c:3223 #: ldlang.c:3232
msgid "%F%P: invalid data statement\n" msgid "%F%P: invalid data statement\n"
msgstr "" msgstr ""
#: ldlang.c:3260 #: ldlang.c:3269
msgid "%F%P: invalid reloc statement\n" msgid "%F%P: invalid reloc statement\n"
msgstr "" msgstr ""
#: ldlang.c:3396 #: ldlang.c:3405
msgid "%P%F:%s: can't set start address\n" msgid "%P%F:%s: can't set start address\n"
msgstr "" msgstr ""
#: ldlang.c:3409 ldlang.c:3426 #: ldlang.c:3418 ldlang.c:3435
msgid "%P%F: can't set start address\n" msgid "%P%F: can't set start address\n"
msgstr "" msgstr ""
#: ldlang.c:3421 #: ldlang.c:3430
msgid "%P: warning: cannot find entry symbol %s; defaulting to %V\n" msgid "%P: warning: cannot find entry symbol %s; defaulting to %V\n"
msgstr "" msgstr ""
#: ldlang.c:3431 #: ldlang.c:3440
msgid "%P: warning: cannot find entry symbol %s; not setting start address\n" msgid "%P: warning: cannot find entry symbol %s; not setting start address\n"
msgstr "" msgstr ""
#: ldlang.c:3473 #: ldlang.c:3529
msgid "" msgid ""
"%P: warning: %s architecture of input file `%B' is incompatible with %s " "%P: warning: %s architecture of input file `%B' is incompatible with %s "
"output\n" "output\n"
msgstr "" msgstr ""
#: ldlang.c:3494 #: ldlang.c:3550
msgid "%E%X: failed to merge target specific data of file %B\n" msgid "%E%X: failed to merge target specific data of file %B\n"
msgstr "" msgstr ""
#: ldlang.c:3581 #: ldlang.c:3637
msgid "" msgid ""
"\n" "\n"
"Allocating common symbols\n" "Allocating common symbols\n"
msgstr "" msgstr ""
#: ldlang.c:3582 #: ldlang.c:3638
msgid "" msgid ""
"Common symbol size file\n" "Common symbol size file\n"
"\n" "\n"
@ -659,43 +659,43 @@ msgstr ""
#. This message happens when using the #. This message happens when using the
#. svr3.ifile linker script, so I have #. svr3.ifile linker script, so I have
#. disabled it. #. disabled it.
#: ldlang.c:3664 #: ldlang.c:3720
msgid "%P: no [COMMON] command, defaulting to .bss\n" msgid "%P: no [COMMON] command, defaulting to .bss\n"
msgstr "" msgstr ""
#: ldlang.c:3723 #: ldlang.c:3779
msgid "%P%F: invalid syntax in flags\n" msgid "%P%F: invalid syntax in flags\n"
msgstr "" msgstr ""
#: ldlang.c:4312 #: ldlang.c:4368
msgid "%P%Fmultiple STARTUP files\n" msgid "%P%Fmultiple STARTUP files\n"
msgstr "" msgstr ""
#: ldlang.c:4582 #: ldlang.c:4638
msgid "%F%P: bfd_record_phdr failed: %E\n" msgid "%F%P: bfd_record_phdr failed: %E\n"
msgstr "" msgstr ""
#: ldlang.c:4601 #: ldlang.c:4657
msgid "%X%P: section `%s' assigned to non-existent phdr `%s'\n" msgid "%X%P: section `%s' assigned to non-existent phdr `%s'\n"
msgstr "" msgstr ""
#: ldlang.c:4916 #: ldlang.c:4972
msgid "%X%P: unknown language `%s' in version information\n" msgid "%X%P: unknown language `%s' in version information\n"
msgstr "" msgstr ""
#: ldlang.c:4965 #: ldlang.c:5021
msgid "%X%P: duplicate version tag `%s'\n" msgid "%X%P: duplicate version tag `%s'\n"
msgstr "" msgstr ""
#: ldlang.c:4978 ldlang.c:4991 #: ldlang.c:5034 ldlang.c:5047
msgid "%X%P: duplicate expression `%s' in version information\n" msgid "%X%P: duplicate expression `%s' in version information\n"
msgstr "" msgstr ""
#: ldlang.c:5028 #: ldlang.c:5084
msgid "%X%P: unable to find version dependency `%s'\n" msgid "%X%P: unable to find version dependency `%s'\n"
msgstr "" msgstr ""
#: ldlang.c:5050 #: ldlang.c:5106
msgid "%X%P: unable to read .exports section contents" msgid "%X%P: unable to read .exports section contents"
msgstr "" msgstr ""