aboutsummaryrefslogtreecommitdiff
path: root/gcc/collect2.c
diff options
context:
space:
mode:
authorDave Korn <dave.korn.cygwin@gmail.com>2010-04-27 02:22:40 +0000
committerDave Korn <davek@gcc.gnu.org>2010-04-27 02:22:40 +0000
commit3bec79c52e613995dd3b07b119a67cd7ad3d72a8 (patch)
treef1cd7b961ac18dc1a7983cdd108f5b91bbc0cb46 /gcc/collect2.c
parent45c384e375c0a05accdd60deaf54d0727dab9feb (diff)
downloadgcc-3bec79c52e613995dd3b07b119a67cd7ad3d72a8.zip
gcc-3bec79c52e613995dd3b07b119a67cd7ad3d72a8.tar.gz
gcc-3bec79c52e613995dd3b07b119a67cd7ad3d72a8.tar.bz2
re PR lto/42776 (LTO doesn't work on non-ELF platforms.)
ChangeLog: PR lto/42776 * configure.ac (--enable-lto): Refactor handling so libelf tests are only performed inside then-clause of ACX_ELF_TARGET_IFELSE, and allow LTO to be explicitly enabled on non-ELF platforms that are known to support it inside else-clause. * configure: Regenerate. gcc/ChangeLog: PR lto/42776 * configure.ac (gcc_cv_as_section_has_align): Set if installed binutils supports extended .section directive needed by LTO, or warn if older binutils found. (LTO_BINARY_READER): New AC_SUBST'd variable. (LTO_USE_LIBELF): Likewise. * gcc/config.gcc (lto_binary_reader): New target-specific configure variable. * gcc/Makefile.in (LTO_BINARY_READER): Import AC_SUBST'd autoconf var. (LTO_USE_LIBELF): Likewise. * configure: Regenerate. * collect2.c (is_elf): Rename from this ... (is_elf_or_coff): ... to this, and recognize and allow i386 COFF object files in addition to ELF-formatted ones. (scan_prog_file): Caller updated. Also allow for LTO info marker symbol to be prefixed or not by an extra underscore. * config/i386/t-cygming (winnt.o): Also depend on LTO_STREAMER_H. * config/i386/winnt.c: Also #include lto-streamer.h (i386_pe_asm_named_section): Specify 1-byte section alignment for LTO named sections. (i386_pe_asm_output_aligned_decl_common): Add comment. (i386_pe_maybe_record_exported_symbol): Allow decl arg to be NULL. gcc/lto/ChangeLog: PR lto/42776 * Make-lang.in (LTO_OBJS): Use LTO_BINARY_READER instead of hardcoding 'lto-elf.o'. ($(LTO_EXE)): Use LTO_USE_LIBELF instead of hardcoding '-lelf'. * lto-coff.h: New file. * lto-coff.c: Likewise. gcc/testsuite/ChangeLog: PR lto/42776 * lib/lto.exp (lto_prune_vis_warns): New function. (lto-link-and-maybe-run): Call it. From-SVN: r158762
Diffstat (limited to 'gcc/collect2.c')
-rw-r--r--gcc/collect2.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 120369a..ad66202 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -2548,19 +2548,21 @@ write_aix_file (FILE *stream, struct id *list)
be in ELF format. */
static bool
-is_elf (const char *prog_name)
+is_elf_or_coff (const char *prog_name)
{
FILE *f;
char buf[4];
static char magic[4] = { 0x7f, 'E', 'L', 'F' };
+ static char coffmag[2] = { 0x4c, 0x01 };
- f = fopen (prog_name, "r");
+ f = fopen (prog_name, "rb");
if (f == NULL)
return false;
if (fread (buf, sizeof (buf), 1, f) != 1)
buf[0] = 0;
fclose (f);
- return memcmp (buf, magic, sizeof (magic)) == 0;
+ return memcmp (buf, magic, sizeof (magic)) == 0
+ || memcmp (buf, coffmag, sizeof (coffmag)) == 0;
}
/* Generic version to scan the name list of the loaded program for
@@ -2587,10 +2589,10 @@ scan_prog_file (const char *prog_name, scanpass which_pass,
if (which_pass == PASS_SECOND)
return;
- /* LTO objects must be in ELF format. This check prevents
+ /* LTO objects must be in a known format. This check prevents
us from accepting an archive containing LTO objects, which
gcc cannnot currently handle. */
- if (which_pass == PASS_LTOINFO && !is_elf (prog_name))
+ if (which_pass == PASS_LTOINFO && !is_elf_or_coff (prog_name))
return;
/* If we do not have an `nm', complain. */
@@ -2670,9 +2672,9 @@ scan_prog_file (const char *prog_name, scanpass which_pass,
/* Look for the LTO info marker symbol, and add filename to
the LTO objects list if found. */
for (p = buf; (ch = *p) != '\0' && ch != '\n'; p++)
- if (ch == ' '
- && (strncmp (p + 1, "__gnu_lto_v1", 12) == 0)
- && ISSPACE (p[13]))
+ if (ch == ' ' && p[1] == '_' && p[2] == '_'
+ && (strncmp (p + (p[3] == '_' ? 2 : 1), "__gnu_lto_v1", 12) == 0)
+ && ISSPACE (p[p[3] == '_' ? 14 : 13]))
{
add_lto_object (&lto_objects, prog_name);