This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] LTO plugin for coff, part 1: break out ELF-specific code and enable COFF builds


    Hello team,

  I'm trying to get the full LTO architecture working on COFF, and to that end
I've recently posted patches to the binutils list implementing the linker
plugin API in GNU LD(*); it should be available in the shortly-forthcoming
next (2.21) release series.  Now I'm ready to start on the GCC end of things,
so here's the first step toward that end.

  This patch separates out the ELF-specific code from the LTO plugin into a
separate source file, and adds autoconfigury to select that or a COFF-specific
source file at build time.  It also adds a configure-time option,
--enable-lto-plugin, which forcibly overrides the default decision about
whether or not to build the LTO plugin.

  There is no functionality in the COFF version just yet; this simply puts the
infrastructure into the right shape.  This means that the plugin it builds
should work "correctly" in the sense that it won't break the link if it's
used, it simply won't claim any files even if they do contain LTO IR, and the
fallback of linking the non-WPA'd native object code will make everything work
as before.  Adding the actual COFF reader functionality will come as a
follow-up patch, hopefully before the end of Stage 1.

  I didn't do anything about Mach-O yet, I suppose I could have added an
equivalent stub file but I'm not set up for testing that target.  The main
benefit of committing this patch early is that it means any further
ELF-specific code has somewhere to go that leaves the core code format
agnostic, and for that it makes no difference whether I add one extra
stubbed-out format-dependent file or two.

  I've bootstrapped and tested this (C and C++ only) on i686-linux-pc-gnu just
to make sure I didn't break anything in the refactoring (there were no
regressions), and I've bootstrapped it on i686-pc-cygwin to make sure it
correctly builds and installs the plugin.

  Subsequent patches will implement the COFF reader functionality and deal
with any tweakage necessary to the plugin-related specs strings to make GCC
actually use the plugin for linking with LD, and a final patch would then
enable both LTO and the plugin by default on the supported COFF targets.

  I haven't added user-visible documentation for this option while it's
experimental, I don't think it would be useful at this stage.  If reviewers
think that's the wrong call, please say so.

ChangeLog:

	* configure.ac (--enable-lto-plugin): New AC_ARG_ENABLE to force the
	lto plugin to be built even without gold being present and enabled.
	* configure: Regenerate.

lto-plugin/ChangeLog:

	* configure.ac: Source config.gcc to determine lto_binary_reader.
	(LTO_FORMAT): New AC_SUBST variable.
	* Makefile.am (LTO_FORMAT): Import.
	(liblto_plugin_la_SOURCES): Add object format dependent module.
	(liblto_plugin_la_LIBADD): Allow for both PIC and non-PIC libiberty,
	and work around libtool warning.
	* configure: Regenerate.
	* Makefile.in: Likewise.

	* lto-plugin.c (LTO_SECTION_PREFIX): Move to new lto-plugin.h
	(struct sym_aux): Likewise.
	(struct plugin_symtab): Likewise.
	(struct plugin_file_info): Likewise.
	(add_symbols):  Make non-static.
	(claimed_files): Likewise.
	(num_claimed_files): Likewise.
	(claim_file_handler): Likewise.
	(onload_format_checks): Likewise.
	(check): Likewise.
	(translate): Likewise.
	(parse_table_entry): Likewise.
	(resolve_conflicts): Likewise.
	(process_symtab): Move to new lto-plugin-elf.c object format dependent
	source file.
	(claim_file_handler): Likewise.
	(onload): Call new onload_format_checks function.

	* lto-plugin-elf.c (process_symtab): Move here.
	(claim_file_handler): Likewise.
	(onload_format_checks): New function factored out from onload.
	* lto-plugin-coff.c (claim_file_handler): New function stub.
	(onload_format_checks): Likewise.

	* lto-plugin.h: New file.
	(LTO_SECTION_PREFIX): Move here.
	(struct sym_aux): Likewise.
	(struct plugin_symtab): Likewise.
	(struct plugin_file_info): Likewise.
	(add_symbols):  Declare extern.
	(claimed_files): Likewise.
	(num_claimed_files): Likewise.
	(claim_file_handler): Likewise.
	(onload_format_checks): Likewise.
	(check): Likewise.
	(translate): Likewise.
	(parse_table_entry):
	(resolve_conflicts): Likewise.
	(process_symtab): Likewise.
	(onload_format_checks): Add new function prototype.

  Is this OK for trunk?

    cheers,
      DaveK

-- 
(*) - http://sourceware.org/ml/binutils/2010-09/threads.html#00392

Index: configure.ac
===================================================================
--- configure.ac	(revision 164643)
+++ configure.ac	(working copy)
@@ -366,6 +366,11 @@ ENABLE_GOLD=no)
     ;;
   esac
 
+AC_ARG_ENABLE(lto-plugin,
+[[  --enable-lto-plugin     build lto plugin even without gold]],
+ENABLE_LTO_PLUGIN=$enableval,
+ENABLE_LTO_PLUGIN=no)
+
 # Configure extra directories which are host specific
 
 case "${host}" in
@@ -1889,6 +1894,16 @@ if test -d ${srcdir}/gcc; then
       extra_host_libiberty_configure_flags=--enable-shared
     fi
   fi
+
+  # Check if the plugin was force-enabled.  Take care not to
+  # add it to the configdirs list twice if that is the case.
+  if test "${ENABLE_LTO_PLUGIN}" = "yes" ; then
+    case ${configdirs} in
+      *lto-plugin*) ;;
+      *) configdirs="$configdirs lto-plugin"
+        extra_host_libiberty_configure_flags=--enable-shared ;;
+    esac
+  fi
   AC_SUBST(extra_host_libiberty_configure_flags)
 
   missing_languages=`echo ",$enable_languages," | sed -e s/,all,/,/ -e s/,c,/,/ `
Index: lto-plugin/configure.ac
===================================================================
--- lto-plugin/configure.ac	(revision 164643)
+++ lto-plugin/configure.ac	(working copy)
@@ -9,6 +9,14 @@ AC_ARG_VAR(LIBELFLIBS,[How to link libelf])
 AC_ARG_VAR(LIBELFINC,[How to find libelf include files])
 AM_PROG_LIBTOOL
 AC_SUBST(target_noncanonical)
+. ${srcdir}/../gcc/config.gcc
+if test x${lto_binary_reader} = xlto-coff ;
+then
+  LTO_FORMAT=coff
+else
+  LTO_FORMAT=elf
+fi
+AC_SUBST(LTO_FORMAT)
 AC_TYPE_UINT64_T
 AC_CONFIG_FILES(Makefile)
 AC_OUTPUT
Index: lto-plugin/Makefile.am
===================================================================
--- lto-plugin/Makefile.am	(revision 164643)
+++ lto-plugin/Makefile.am	(working copy)
@@ -11,13 +11,19 @@ libexecsubdir := $(libexecdir)/gcc/$(target_noncan
 LIBELFLIBS = @LIBELFLIBS@
 LIBELFINC = @LIBELFINC@
 
+# Which object format to parse.
+LTO_FORMAT = @LTO_FORMAT@
+
 AM_CPPFLAGS = -I$(top_srcdir)/../include $(LIBELFINC)
 AM_CFLAGS = -Wall -Werror
 
 libexecsub_LTLIBRARIES = liblto_plugin.la
 
-liblto_plugin_la_SOURCES = lto-plugin.c
-liblto_plugin_la_LIBADD = $(LIBELFLIBS) ../libiberty/pic/libiberty.a
+liblto_plugin_la_SOURCES = lto-plugin.c lto-plugin-$(LTO_FORMAT).c
+liblto_plugin_la_LIBADD = $(LIBELFLIBS) \
+	$(if $(wildcard ../libiberty/pic/libiberty.a),../libiberty/pic/libiberty.a,)
+liblto_plugin_la_LDFLAGS = -no-undefined -bindir $(libexecsubdir) \
+	$(if $(wildcard ../libiberty/pic/libiberty.a),,-Wc,../libiberty/libiberty.a)
 
 all: copy_lto_plugin
 
Index: lto-plugin/lto-plugin.h
===================================================================
--- lto-plugin/lto-plugin.h	(revision 0)
+++ lto-plugin/lto-plugin.h	(revision 0)
@@ -0,0 +1,84 @@
+/* Common declarations for LTO plugin for gold and/or GNU ld.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+   Contributed by Rafael Avila de Espindola (espindola@google.com).
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include <stdbool.h>
+#include "plugin-api.h"
+
+/* LTO magic section name.  */
+
+#define LTO_SECTION_PREFIX ".gnu.lto_.symtab"
+
+/* The part of the symbol table the plugin has to keep track of. Note that we
+   must keep SYMS until all_symbols_read is called to give the linker time to
+   copy the symbol information. */
+
+struct sym_aux
+{
+  uint32_t slot;
+  unsigned id;
+  unsigned next_conflict;
+};
+
+struct plugin_symtab
+{
+  int nsyms;
+  struct sym_aux *aux;
+  struct ld_plugin_symbol *syms;
+  unsigned id;
+};
+
+/* All that we have to remember about a file. */
+
+struct plugin_file_info
+{
+  char *name;
+  void *handle;
+  struct plugin_symtab symtab;
+  struct plugin_symtab conflicts;
+};
+
+/* These are the methods supplied by one of the object format
+   dependent files lto-plugin-elf.c or lto-plugin-coff.c  */
+
+extern enum ld_plugin_status claim_file_handler 
+		(const struct ld_plugin_input_file *file, int *claimed);
+
+extern enum ld_plugin_status onload_format_checks (struct ld_plugin_tv *tv);
+
+/* These methods are made available to the object format
+   dependent files.  */
+
+extern void check (bool gate, enum ld_plugin_level level, const char *text);
+
+extern void translate (char *data, char *end, struct plugin_symtab *out);
+
+extern char *parse_table_entry (char *p, struct ld_plugin_symbol *entry,
+			struct sym_aux *aux);
+
+extern void resolve_conflicts (struct plugin_symtab *t,
+			struct plugin_symtab *conflicts);
+
+/* And this callback function is exposed.  */
+
+extern ld_plugin_add_symbols add_symbols;
+
+/* Along with these two variables.  */
+
+extern struct plugin_file_info *claimed_files;
+extern unsigned int num_claimed_files;
+
Index: lto-plugin/lto-plugin.c
===================================================================
--- lto-plugin/lto-plugin.c	(revision 164643)
+++ lto-plugin/lto-plugin.c	(working copy)
@@ -1,4 +1,4 @@
-/* LTO plugin for gold.
+/* LTO plugin for gold and/or GNU ld.
    Copyright (C) 2009 Free Software Foundation, Inc.
    Contributed by Rafael Avila de Espindola (espindola@google.com).
 
@@ -45,46 +45,13 @@ along with this program; see the file COPYING3.  I
 #include <stdbool.h>
 #include <libiberty.h>
 #include <hashtab.h>
-
-/* The presence of gelf.h is checked by the toplevel configure script.  */
-#include <gelf.h>
-
-#include "plugin-api.h"
 #include "../gcc/lto/common.h"
 
-/* The part of the symbol table the plugin has to keep track of. Note that we
-   must keep SYMS until all_symbols_read is called to give the linker time to
-   copy the symbol information. */
+/* Common definitions for/from the object format dependent code.  */
+#include "lto-plugin.h"
 
-struct sym_aux
-{
-  uint32_t slot;
-  unsigned id;
-  unsigned next_conflict;
-};
-
-struct plugin_symtab
-{
-  int nsyms;
-  struct sym_aux *aux;
-  struct ld_plugin_symbol *syms;
-  unsigned id;
-};
-
-/* All that we have to remember about a file. */
-
-struct plugin_file_info
-{
-  char *name;
-  void *handle;
-  struct plugin_symtab symtab;
-  struct plugin_symtab conflicts;
-};
-
-
 static char *arguments_file_name;
 static ld_plugin_register_claim_file register_claim_file;
-static ld_plugin_add_symbols add_symbols;
 static ld_plugin_register_all_symbols_read register_all_symbols_read;
 static ld_plugin_get_symbols get_symbols;
 static ld_plugin_register_cleanup register_cleanup;
@@ -92,9 +59,13 @@ static ld_plugin_add_input_file add_input_file;
 static ld_plugin_add_input_library add_input_library;
 static ld_plugin_message message;
 
-static struct plugin_file_info *claimed_files = NULL;
-static unsigned int num_claimed_files = 0;
+/* These are not static because the object format dependent
+   claim_file hooks in lto-plugin-{coff,elf}.c need them.  */
+ld_plugin_add_symbols add_symbols;
 
+struct plugin_file_info *claimed_files = NULL;
+unsigned int num_claimed_files = 0;
+
 static char **output_files = NULL;
 static unsigned int num_output_files = 0;
 
@@ -108,7 +79,7 @@ static bool debug;
 static bool nop;
 static char *resolution_file = NULL;
 
-static void
+void
 check (bool gate, enum ld_plugin_level level, const char *text)
 {
   if (gate)
@@ -129,7 +100,7 @@ check (bool gate, enum ld_plugin_level level, cons
    by P and the result is written in ENTRY. The slot number is stored in SLOT.
    Returns the address of the next entry. */
 
-static char *
+char *
 parse_table_entry (char *p, struct ld_plugin_symbol *entry, 
 		   struct sym_aux *aux)
 {
@@ -191,16 +162,13 @@ parse_table_entry (char *p, struct ld_plugin_symbo
   return p;
 }
 
-#define LTO_SECTION_PREFIX ".gnu.lto_.symtab"
+/* Translate the IL symbol table located between DATA and END. Append the
+   slots and symbols to OUT. */
 
-/* Translate the IL symbol table SYMTAB. Append the slots and symbols to OUT. */
-
-static void
-translate (Elf_Data *symtab, struct plugin_symtab *out)
+void
+translate (char *data, char *end, struct plugin_symtab *out)
 {
   struct sym_aux *aux;
-  char *data = symtab->d_buf;
-  char *end = data + symtab->d_size;
   struct ld_plugin_symbol *syms = NULL;
   int n, len;
 
@@ -224,39 +192,6 @@ parse_table_entry (char *p, struct ld_plugin_symbo
   out->aux = aux;
 }
 
-/* Process all lto symtabs of file ELF. */
-
-static int
-process_symtab (Elf *elf, struct plugin_symtab *out)
-{
-  int found = 0;
-  Elf_Scn *section = 0;
-  GElf_Ehdr header;
-  GElf_Ehdr *t = gelf_getehdr (elf, &header);
-  if (t == NULL)
-    return 0;
-  assert (t == &header);
-
-  while ((section = elf_nextscn(elf, section)) != 0)
-    {
-      GElf_Shdr shdr;
-      GElf_Shdr *tshdr = gelf_getshdr (section, &shdr);
-      const char *t;
-      assert (tshdr == &shdr);
-      t = elf_strptr (elf, header.e_shstrndx, shdr.sh_name);
-      assert (t != NULL);
-      if (strncmp (t, LTO_SECTION_PREFIX, strlen (LTO_SECTION_PREFIX)) == 0) 
-	{
-	  char *s = strrchr (t, '.');
-	  if (s)
-	      sscanf (s, ".%x", &out->id);
-	  translate (elf_getdata (section, NULL), out);
-	  found++;
-	}
-    }
-  return found;
-}
-
 /* Free all memory that is no longer needed after writing the symbol
    resolution. */
 
@@ -686,7 +621,7 @@ static int symbol_strength (struct ld_plugin_symbo
    
    XXX how to handle common? */
 
-static void
+void
 resolve_conflicts (struct plugin_symtab *t, struct plugin_symtab *conflicts)
 {
   htab_t symtab = htab_create (t->nsyms, hash_sym, eq_sym, NULL);
@@ -754,87 +689,6 @@ resolve_conflicts (struct plugin_symtab *t, struct
   htab_delete (symtab);
 }
 
-/* Callback used by gold to check if the plugin will claim FILE. Writes
-   the result in CLAIMED. */
-
-static enum ld_plugin_status
-claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
-{
-  enum ld_plugin_status status;
-  Elf *elf;
-  struct plugin_file_info lto_file;
-  int n;
-
-  memset (&lto_file, 0, sizeof (struct plugin_file_info));
-
-  if (file->offset != 0)
-    {
-      char *objname;
-      Elf *archive;
-      off_t offset;
-      /* We pass the offset of the actual file, not the archive header. */
-      int t = asprintf (&objname, "%s@0x%" PRIx64, file->name,
-                        (int64_t) file->offset);
-      check (t >= 0, LDPL_FATAL, "asprintf failed");
-      lto_file.name = objname;
-
-      archive = elf_begin (file->fd, ELF_C_READ, NULL);
-      check (elf_kind (archive) == ELF_K_AR, LDPL_FATAL,
-             "Not an archive and offset not 0");
-
-      /* elf_rand expects the offset to point to the ar header, not the
-         object itself. Subtract the size of the ar header (60 bytes).
-         We don't uses sizeof (struct ar_hd) to avoid including ar.h */
-
-      offset = file->offset - 60;
-      check (offset == elf_rand (archive, offset), LDPL_FATAL,
-             "could not seek in archive");
-      elf = elf_begin (file->fd, ELF_C_READ, archive);
-      check (elf != NULL, LDPL_FATAL, "could not find archive member");
-      elf_end (archive);
-    }
-  else
-    {
-      lto_file.name = xstrdup (file->name);
-      elf = elf_begin (file->fd, ELF_C_READ, NULL);
-    }
-  lto_file.handle = file->handle;
-
-  *claimed = 0;
-
-  if (!elf)
-    goto err;
-
-  n = process_symtab (elf, &lto_file.symtab);
-  if (n == 0)
-    goto err;
-
-  if (n > 1)
-    resolve_conflicts (&lto_file.symtab, &lto_file.conflicts);
-
-  status = add_symbols (file->handle, lto_file.symtab.nsyms,
-			lto_file.symtab.syms);
-  check (status == LDPS_OK, LDPL_FATAL, "could not add symbols");
-
-  *claimed = 1;
-  num_claimed_files++;
-  claimed_files =
-    xrealloc (claimed_files,
-	      num_claimed_files * sizeof (struct plugin_file_info));
-  claimed_files[num_claimed_files - 1] = lto_file;
-
-  goto cleanup;
-
- err:
-  free (lto_file.name);
-
- cleanup:
-  if (elf)
-    elf_end (elf);
-
-  return LDPS_OK;
-}
-
 /* Parse the plugin options. */
 
 static void
@@ -873,8 +727,9 @@ onload (struct ld_plugin_tv *tv)
   struct ld_plugin_tv *p;
   enum ld_plugin_status status;
 
-  unsigned version = elf_version (EV_CURRENT);
-  check (version != EV_NONE, LDPL_FATAL, "invalid ELF version");
+  status = onload_format_checks (tv);
+  if (status != LDPS_OK)
+    return status;
 
   p = tv;
   while (p->tv_tag)
Index: lto-plugin/lto-plugin-elf.c
===================================================================
--- lto-plugin/lto-plugin-elf.c	(revision 0)
+++ lto-plugin/lto-plugin-elf.c	(revision 0)
@@ -0,0 +1,157 @@
+/* LTO plugin for gold.
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+   Contributed by Rafael Avila de Espindola (espindola@google.com).
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <libiberty.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+/* The presence of gelf.h is checked by the toplevel configure script.  */
+#include <gelf.h>
+
+/* Common definitions that the object format dependent code needs.  */
+#include "lto-plugin.h"
+
+/* Process all lto symtabs of file ELF. */
+
+static int
+process_symtab (Elf *elf, struct plugin_symtab *out)
+{
+  int found = 0;
+  Elf_Scn *section = 0;
+  GElf_Ehdr header;
+  GElf_Ehdr *t = gelf_getehdr (elf, &header);
+  if (t == NULL)
+    return 0;
+  assert (t == &header);
+
+  while ((section = elf_nextscn(elf, section)) != 0)
+    {
+      GElf_Shdr shdr;
+      GElf_Shdr *tshdr = gelf_getshdr (section, &shdr);
+      Elf_Data *symtab;
+      const char *t;
+      assert (tshdr == &shdr);
+      t = elf_strptr (elf, header.e_shstrndx, shdr.sh_name);
+      assert (t != NULL);
+      if (strncmp (t, LTO_SECTION_PREFIX, strlen (LTO_SECTION_PREFIX)) == 0) 
+	{
+	  char *s = strrchr (t, '.');
+	  if (s)
+	      sscanf (s, ".%x", &out->id);
+	  symtab = elf_getdata (section, NULL);
+	  translate (symtab->d_buf, symtab->d_buf + symtab->d_size, out);
+	  found++;
+	}
+    }
+  return found;
+}
+
+/* Callback used by gold to check if the plugin will claim FILE. Writes
+   the result in CLAIMED. */
+
+enum ld_plugin_status
+claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
+{
+  enum ld_plugin_status status;
+  Elf *elf;
+  struct plugin_file_info lto_file;
+  int n;
+
+  memset (&lto_file, 0, sizeof (struct plugin_file_info));
+
+  if (file->offset != 0)
+    {
+      char *objname;
+      Elf *archive;
+      off_t offset;
+      /* We pass the offset of the actual file, not the archive header. */
+      int t = asprintf (&objname, "%s@0x%" PRIx64, file->name,
+                        (int64_t) file->offset);
+      check (t >= 0, LDPL_FATAL, "asprintf failed");
+      lto_file.name = objname;
+
+      archive = elf_begin (file->fd, ELF_C_READ, NULL);
+      check (elf_kind (archive) == ELF_K_AR, LDPL_FATAL,
+             "Not an archive and offset not 0");
+
+      /* elf_rand expects the offset to point to the ar header, not the
+         object itself. Subtract the size of the ar header (60 bytes).
+         We don't uses sizeof (struct ar_hd) to avoid including ar.h */
+
+      offset = file->offset - 60;
+      check (offset == elf_rand (archive, offset), LDPL_FATAL,
+             "could not seek in archive");
+      elf = elf_begin (file->fd, ELF_C_READ, archive);
+      check (elf != NULL, LDPL_FATAL, "could not find archive member");
+      elf_end (archive);
+    }
+  else
+    {
+      lto_file.name = xstrdup (file->name);
+      elf = elf_begin (file->fd, ELF_C_READ, NULL);
+    }
+  lto_file.handle = file->handle;
+
+  *claimed = 0;
+
+  if (!elf)
+    goto err;
+
+  n = process_symtab (elf, &lto_file.symtab);
+  if (n == 0)
+    goto err;
+
+  if (n > 1)
+    resolve_conflicts (&lto_file.symtab, &lto_file.conflicts);
+
+  status = add_symbols (file->handle, lto_file.symtab.nsyms,
+			lto_file.symtab.syms);
+  check (status == LDPS_OK, LDPL_FATAL, "could not add symbols");
+
+  *claimed = 1;
+  num_claimed_files++;
+  claimed_files =
+    xrealloc (claimed_files,
+	      num_claimed_files * sizeof (struct plugin_file_info));
+  claimed_files[num_claimed_files - 1] = lto_file;
+
+  goto cleanup;
+
+ err:
+  free (lto_file.name);
+
+ cleanup:
+  if (elf)
+    elf_end (elf);
+
+  return LDPS_OK;
+}
+
+/* Method called first thing at onload time to perform sanity checks.  */
+
+enum ld_plugin_status
+onload_format_checks (struct ld_plugin_tv *tv)
+{
+  unsigned version = elf_version (EV_CURRENT);
+  check (version != EV_NONE, LDPL_FATAL, "invalid ELF version");
+  return LDPS_OK;
+}
+
Index: lto-plugin/lto-plugin-coff.c
===================================================================
--- lto-plugin/lto-plugin-coff.c	(revision 0)
+++ lto-plugin/lto-plugin-coff.c	(revision 0)
@@ -0,0 +1,38 @@
+/* LTO plugin for gold.
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* Common definitions that the object format dependent code needs.  */
+#include "lto-plugin.h"
+
+/* Callback used by gold to check if the plugin will claim FILE. Writes
+   the result in CLAIMED. */
+
+enum ld_plugin_status
+claim_file_handler (const struct ld_plugin_input_file *file, int *claimed)
+{
+  /* To be implemented; for now, simply do nothing.  */
+  return LDPS_OK;
+}
+
+/* Method called first thing at onload time to perform sanity checks.  */
+
+enum ld_plugin_status
+onload_format_checks (struct ld_plugin_tv *tv)
+{
+  return LDPS_OK;
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]