X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=lto-plugin%2Flto-plugin.c;h=5ca4c9a27a31269df761b6cde3fdffd06adfc3a3;hp=83b61d53188ff1784c77c2d96c7a20ebad35aaa1;hb=13ac7a0f8ccbc9b5c1edb8e23ff43d62b0ba0534;hpb=a0f802f19842e68b27d568b9aa6bdbf530df4b2f diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index 83b61d53188..5ca4c9a27a3 100644 --- a/lto-plugin/lto-plugin.c +++ b/lto-plugin/lto-plugin.c @@ -35,6 +35,9 @@ along with this program; see the file COPYING3. If not see #ifdef HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_STDINT_H +#include +#endif #include #include #include @@ -44,8 +47,15 @@ along with this program; see the file COPYING3. If not see #include #include #include +#ifdef HAVE_SYS_WAIT_H #include -#include +#endif +#ifndef WIFEXITED +#define WIFEXITED(S) (((S) & 0xff) == 0) +#endif +#ifndef WEXITSTATUS +#define WEXITSTATUS(S) (((S) & 0xff00) >> 8) +#endif #include #include #include "../gcc/lto/common.h" @@ -138,8 +148,8 @@ static int lto_wrapper_num_args; static char **pass_through_items = NULL; static unsigned int num_pass_through_items; -static bool debug; -static bool nop; +static char debug; +static char nop; static char *resolution_file = NULL; /* Set by default from configure.ac, but can be overridden at runtime @@ -148,7 +158,7 @@ static char *resolution_file = NULL; static enum symbol_style sym_style = SYM_STYLE; static void -check (bool gate, enum ld_plugin_level level, const char *text) +check_1 (int gate, enum ld_plugin_level level, const char *text) { if (gate) return; @@ -164,6 +174,11 @@ check (bool gate, enum ld_plugin_level level, const char *text) } } +/* This little wrapper allows check to be called with a non-integer + first argument, such as a pointer that must be non-NULL. We can't + use c99 bool type to coerce it into range, so we explicitly test. */ +#define check(GATE, LEVEL, TEXT) check_1 (((GATE) != 0), (LEVEL), (TEXT)) + /* Parse an entry of the IL symbol table. The data to be parsed is pointed by P and the result is written in ENTRY. The slot number is stored in SLOT. Returns the address of the next entry. */ @@ -205,7 +220,7 @@ parse_table_entry (char *p, struct ld_plugin_symbol *entry, entry->name = concat ("_", p, NULL); break; default: - check (false, LDPL_FATAL, "invalid symbol style requested"); + check (0, LDPL_FATAL, "invalid symbol style requested"); break; } while (*p) @@ -454,7 +469,10 @@ add_output_files (FILE *f) buf = s; cont: if (!fgets (buf, piece, f)) - break; + { + free (s); + break; + } len = strlen (s); if (s[len - 1] != '\n') { @@ -825,9 +843,14 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed) if (file->offset != 0) { char *objname; - /* 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); + /* We pass the offset of the actual file, not the archive header. + Can't use PRIx64, because that's C99, so we have to print the + 64-bit hex int as two 32-bit ones. */ + int lo, hi; + lo = file->offset & 0xffffffff; + hi = ((int64_t)file->offset >> 32) & 0xffffffff; + int t = hi ? asprintf (&objname, "%s@0x%x%08x", file->name, lo, hi) + : asprintf (&objname, "%s@0x%x", file->name, lo); check (t >= 0, LDPL_FATAL, "asprintf failed"); lto_file.name = objname; }