1997-08-11 22:23:53 +02:00
|
|
|
|
/* Scan linker error messages for missing template instantiations and provide
|
|
|
|
|
them.
|
|
|
|
|
|
2005-03-29 21:39:35 +02:00
|
|
|
|
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2003, 2004, 2005
|
2003-07-06 14:35:56 +02:00
|
|
|
|
Free Software Foundation, Inc.
|
1997-08-11 22:23:53 +02:00
|
|
|
|
Contributed by Jason Merrill (jason@cygnus.com).
|
|
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
|
This file is part of GCC.
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
|
GCC 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 2, or (at your option) any later
|
|
|
|
|
version.
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
|
GCC 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.
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
Makefile.in, [...]: replace "GNU CC" with "GCC".
* Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c,
bitmap.h, builtin-types.def, builtins.c, builtins.def,
c-aux-info.c, c-common.c, c-common.def, c-common.h,
c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c,
c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in,
c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c,
caller-save.c, calls.c, collect2.c, collect2.h, combine.c,
conditions.h, config.gcc, configure.frag, configure.in,
conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c,
cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h,
dependence.c, df.c, df.h, diagnostic.c, diagnostic.h,
doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c,
dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c,
emit-rtl.c, errors.c, errors.h, except.c, except.h,
exgettext, explow.c, expmed.c, expr.c, expr.h, final.c,
fixproto, flags.h, flow.c, fold-const.c, fp-test.c,
function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp,
gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c,
gencheck.c, gencodes.c, genconfig.c, genemit.c,
genextract.c, genflags.c, gengenrtl.c, genmultilib,
genopinit.c, genoutput.c, genpeep.c, genrecog.c,
gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c,
ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c,
graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h,
gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h,
gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h,
hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h,
integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c,
libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h,
machmode.def, machmode.h, main.c, mbchar.c, mbchar.h,
mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk,
mkmap-symver.awk, optabs.c, output.h, params.c, params.def,
params.h, predict.c, predict.def, predict.h, prefix.c,
prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c,
read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c,
regclass.c, regmove.c, regrename.c, regs.h, reload.c,
reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c,
rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h,
sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c,
sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c,
ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c,
stringpool.c, system.h, timevar.c, timevar.def, timevar.h,
tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h,
tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h,
unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h,
unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c,
xcoffout.h: replace "GNU CC" with "GCC".
From-SVN: r45105
2001-08-22 16:35:51 +02:00
|
|
|
|
along with GCC; see the file COPYING. If not, write to the Free
|
2005-06-25 04:02:01 +02:00
|
|
|
|
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
|
02110-1301, USA. */
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
#include "config.h"
|
Major cutover to using system.h:
* Makefile.in (alias.o, bitmap.o, c-aux-info.o, c-common.o,
c-decl.o, c-iterate.o, c-lang.o, c-lex.o, c-pragma.o, c-typeck.o,
caller-save.o, calls.o, collect2.o, combine.o, cse.o, dbxout.o,
dwarf2out.o, dwarfout.o, emit-rtl.o, except.o, explow.o, expmed.o,
expr.o, final.o, flow.o, function.o, getpwd.o, global.o,
integrate.o, jump.o, local-alloc.o, loop.o, optabs.o, pexecute.o,
prefix.o, print-rtl.o, print-tree.o, profile.o, real.o, recog.o,
reg-stack.o, regclass.o, regmove.o, reload.o, reload1.o, reorg.o,
rtl.o, rtlanal.o, sdbout.o, stmt.o, stor-layout.o, stupid.o,
tlink.o, toplev.o, tree.o, unroll.o, varasm.o, xcoffout.o): Depend
on system.h.
* alias.c, bitmap.c, c-aux-info.c, c-common.c, c-decl.c,
c-iterate.c, c-lang.c, c-lex.c, c-pragma.c, c-typeck.c,
caller-save.c, calls.c, collect2.c, combine.c, cse.c, dbxout.c,
dwarf2out.c, dwarfout.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, flow.c, function.c, gcc.c, getpwd.c, global.c,
integrate.c, jump.c, local-alloc.c, loop.c, optabs.c, pexecute.c,
prefix.c, print-rtl.c, print-tree.c, profile.c, real.c, recog.c,
reg-stack.c, regclass.c, regmove.c, reload.c, reload1.c, reorg.c,
rtl.c, rtlanal.c, sched.c, sdbout.c, stmt.c, stor-layout.c,
stupid.c, tlink.c, toplev.c, tree.c, unroll.c, varasm.c,
xcoffout.c: Include system.h. Organize include ordering so
that stdarg/varargs comes before other system headers. Remove
spurious casts of functions assured of a prototype in system.h.
From-SVN: r18726
1998-03-20 15:58:42 +01:00
|
|
|
|
#include "system.h"
|
2002-12-16 19:23:00 +01:00
|
|
|
|
#include "coretypes.h"
|
|
|
|
|
#include "tm.h"
|
2000-06-29 19:31:03 +02:00
|
|
|
|
#include "intl.h"
|
2002-06-04 09:11:05 +02:00
|
|
|
|
#include "obstack.h"
|
|
|
|
|
#include "hashtab.h"
|
1997-08-11 22:23:53 +02:00
|
|
|
|
#include "demangle.h"
|
1998-12-10 11:48:27 +01:00
|
|
|
|
#include "collect2.h"
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
#define MAX_ITERATIONS 17
|
|
|
|
|
|
|
|
|
|
/* Defined in the automatically-generated underscore.c. */
|
|
|
|
|
extern int prepends_underscore;
|
|
|
|
|
|
|
|
|
|
static int tlink_verbose;
|
2004-08-25 22:51:19 +02:00
|
|
|
|
|
|
|
|
|
static char initial_cwd[MAXPATHLEN + 1];
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
/* Hash table boilerplate for working with htab_t. We have hash tables
|
1999-01-26 20:34:06 +01:00
|
|
|
|
for symbol names, file names, and demangled symbols. */
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
typedef struct symbol_hash_entry
|
|
|
|
|
{
|
2002-06-04 09:11:05 +02:00
|
|
|
|
const char *key;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
struct file_hash_entry *file;
|
|
|
|
|
int chosen;
|
|
|
|
|
int tweaking;
|
|
|
|
|
int tweaked;
|
|
|
|
|
} symbol;
|
|
|
|
|
|
|
|
|
|
typedef struct file_hash_entry
|
|
|
|
|
{
|
2002-06-04 09:11:05 +02:00
|
|
|
|
const char *key;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
const char *args;
|
|
|
|
|
const char *dir;
|
|
|
|
|
const char *main;
|
|
|
|
|
int tweaking;
|
|
|
|
|
} file;
|
|
|
|
|
|
|
|
|
|
typedef struct demangled_hash_entry
|
|
|
|
|
{
|
2002-06-04 09:11:05 +02:00
|
|
|
|
const char *key;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
const char *mangled;
|
|
|
|
|
} demangled;
|
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
/* Hash and comparison functions for these hash tables. */
|
|
|
|
|
|
2003-07-06 14:35:56 +02:00
|
|
|
|
static int hash_string_eq (const void *, const void *);
|
|
|
|
|
static hashval_t hash_string_hash (const void *);
|
2002-06-04 09:11:05 +02:00
|
|
|
|
|
|
|
|
|
static int
|
2003-07-06 14:35:56 +02:00
|
|
|
|
hash_string_eq (const void *s1_p, const void *s2_p)
|
2002-06-04 09:11:05 +02:00
|
|
|
|
{
|
2002-11-16 19:33:29 +01:00
|
|
|
|
const char *const *s1 = (const char *const *) s1_p;
|
|
|
|
|
const char *s2 = (const char *) s2_p;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
return strcmp (*s1, s2) == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static hashval_t
|
2003-07-06 14:35:56 +02:00
|
|
|
|
hash_string_hash (const void *s_p)
|
2002-06-04 09:11:05 +02:00
|
|
|
|
{
|
2002-11-16 19:33:29 +01:00
|
|
|
|
const char *const *s = (const char *const *) s_p;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
return (*htab_hash_string) (*s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static htab_t symbol_table;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
2003-07-06 14:35:56 +02:00
|
|
|
|
static struct symbol_hash_entry * symbol_hash_lookup (const char *, int);
|
|
|
|
|
static struct file_hash_entry * file_hash_lookup (const char *);
|
|
|
|
|
static struct demangled_hash_entry *demangled_hash_lookup (const char *, int);
|
|
|
|
|
static void symbol_push (symbol *);
|
|
|
|
|
static symbol * symbol_pop (void);
|
|
|
|
|
static void file_push (file *);
|
|
|
|
|
static file * file_pop (void);
|
|
|
|
|
static void tlink_init (void);
|
2005-03-31 16:53:17 +02:00
|
|
|
|
static int tlink_execute (const char *, char **, const char *, const char *);
|
2003-07-06 14:35:56 +02:00
|
|
|
|
static char * frob_extension (const char *, const char *);
|
|
|
|
|
static char * obstack_fgets (FILE *, struct obstack *);
|
|
|
|
|
static char * tfgets (FILE *);
|
|
|
|
|
static char * pfgets (FILE *);
|
|
|
|
|
static void freadsym (FILE *, file *, int);
|
|
|
|
|
static void read_repo_file (file *);
|
|
|
|
|
static void maybe_tweak (char *, file *);
|
|
|
|
|
static int recompile_files (void);
|
|
|
|
|
static int read_repo_files (char **);
|
|
|
|
|
static void demangle_new_symbols (void);
|
|
|
|
|
static int scan_linker_output (const char *);
|
Warning fixes:
* c-lex.c (yylex): Remove unused variable `bytes'.
* flow.c (print_rtl_with_bb): Cast the return value of alloca.
* function.c (assign_parms): Wrap variable `varargs_setup' in
macro SETUP_INCOMING_VARARGS.
(thread_prologue_and_epilogue_insns): Mark parameter `f' with
ATTRIBUTE_UNUSED.
* local-alloc.c (no_equiv): Likewise for parameter `store'.
* sched.c (schedule_insns): Remove unused variables `insn' and `next'.
* tlink.c (symbol_hash_newfunc, symbol_hash_lookup,
file_hash_newfunc, file_hash_lookup, demangled_hash_newfunc,
demangled_hash_lookup, symbol_push, symbol_pop, file_push,
file_pop, tlink_init, tlink_execute, frob_extension,
obstack_fgets, tfgets, pfgets, freadsym, read_repo_file,
maybe_tweak, recompile_files, read_repo_files,
demangle_new_symbols, scan_linker_output): Add static prototype.
(symbol_hash_newfunc, file_hash_newfunc, demangled_hash_newfunc):
Make the third argument a `hash_table_key'.
* toplev.c (debug_start_source_file): Mark parameter `filename'
with ATTRIBUTE_UNUSED.
From-SVN: r25871
1999-03-20 20:21:31 +01:00
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Look up an entry in the symbol hash table. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static struct symbol_hash_entry *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
symbol_hash_lookup (const char *string, int create)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
decl.c, [...]: Don't use the PTR macro.
cp:
* cp/decl.c, cp/pt.c, cp/search.c, cp/tree.c: Don't use the PTR
macro.
gcc:
* bitmap.c, builtins.c, c-incpath.c, cgraph.c, config/frv/frv.c,
config/mips/mips.c, cppfiles.c, cpphash.c, cppinit.c, cpplib.c,
dwarf2out.c, dwarfout.c, except.c, expr.c, expr.h, fold-const.c,
function.c, gcc.c, genoutput.c, gensupport.c, global.c,
haifa-sched.c, hashtable.c, ifcvt.c, integrate.c, local-alloc.c,
loop.c, mips-tdump.c, mips-tfile.c, mkdeps.c, protoize.c,
read-rtl.c, recog.h, reload1.c, sbitmap.c, ssa-dce.c,
stringpool.c, tlink.c, tree.c, varasm.c, varray.c: Don't use
the PTR macro.
From-SVN: r68043
2003-06-16 23:41:10 +02:00
|
|
|
|
void **e;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
e = htab_find_slot_with_hash (symbol_table, string,
|
2002-11-16 19:33:29 +01:00
|
|
|
|
(*htab_hash_string) (string),
|
2002-06-04 09:11:05 +02:00
|
|
|
|
create ? INSERT : NO_INSERT);
|
|
|
|
|
if (e == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (*e == NULL)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
2002-06-04 09:11:05 +02:00
|
|
|
|
struct symbol_hash_entry *v;
|
2006-01-31 20:56:55 +01:00
|
|
|
|
*e = v = XCNEW (struct symbol_hash_entry);
|
2002-06-04 09:11:05 +02:00
|
|
|
|
v->key = xstrdup (string);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
2002-06-04 09:11:05 +02:00
|
|
|
|
return *e;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
static htab_t file_table;
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Look up an entry in the file hash table. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static struct file_hash_entry *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
file_hash_lookup (const char *string)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
decl.c, [...]: Don't use the PTR macro.
cp:
* cp/decl.c, cp/pt.c, cp/search.c, cp/tree.c: Don't use the PTR
macro.
gcc:
* bitmap.c, builtins.c, c-incpath.c, cgraph.c, config/frv/frv.c,
config/mips/mips.c, cppfiles.c, cpphash.c, cppinit.c, cpplib.c,
dwarf2out.c, dwarfout.c, except.c, expr.c, expr.h, fold-const.c,
function.c, gcc.c, genoutput.c, gensupport.c, global.c,
haifa-sched.c, hashtable.c, ifcvt.c, integrate.c, local-alloc.c,
loop.c, mips-tdump.c, mips-tfile.c, mkdeps.c, protoize.c,
read-rtl.c, recog.h, reload1.c, sbitmap.c, ssa-dce.c,
stringpool.c, tlink.c, tree.c, varasm.c, varray.c: Don't use
the PTR macro.
From-SVN: r68043
2003-06-16 23:41:10 +02:00
|
|
|
|
void **e;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
e = htab_find_slot_with_hash (file_table, string,
|
2002-11-16 19:33:29 +01:00
|
|
|
|
(*htab_hash_string) (string),
|
2002-06-04 09:11:05 +02:00
|
|
|
|
INSERT);
|
|
|
|
|
if (*e == NULL)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
2002-06-04 09:11:05 +02:00
|
|
|
|
struct file_hash_entry *v;
|
2006-01-31 20:56:55 +01:00
|
|
|
|
*e = v = XCNEW (struct file_hash_entry);
|
2002-06-04 09:11:05 +02:00
|
|
|
|
v->key = xstrdup (string);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
2002-06-04 09:11:05 +02:00
|
|
|
|
return *e;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
static htab_t demangled_table;
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Look up an entry in the demangled name hash table. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static struct demangled_hash_entry *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
demangled_hash_lookup (const char *string, int create)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
decl.c, [...]: Don't use the PTR macro.
cp:
* cp/decl.c, cp/pt.c, cp/search.c, cp/tree.c: Don't use the PTR
macro.
gcc:
* bitmap.c, builtins.c, c-incpath.c, cgraph.c, config/frv/frv.c,
config/mips/mips.c, cppfiles.c, cpphash.c, cppinit.c, cpplib.c,
dwarf2out.c, dwarfout.c, except.c, expr.c, expr.h, fold-const.c,
function.c, gcc.c, genoutput.c, gensupport.c, global.c,
haifa-sched.c, hashtable.c, ifcvt.c, integrate.c, local-alloc.c,
loop.c, mips-tdump.c, mips-tfile.c, mkdeps.c, protoize.c,
read-rtl.c, recog.h, reload1.c, sbitmap.c, ssa-dce.c,
stringpool.c, tlink.c, tree.c, varasm.c, varray.c: Don't use
the PTR macro.
From-SVN: r68043
2003-06-16 23:41:10 +02:00
|
|
|
|
void **e;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
e = htab_find_slot_with_hash (demangled_table, string,
|
2002-11-16 19:33:29 +01:00
|
|
|
|
(*htab_hash_string) (string),
|
2002-06-04 09:11:05 +02:00
|
|
|
|
create ? INSERT : NO_INSERT);
|
|
|
|
|
if (e == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
if (*e == NULL)
|
|
|
|
|
{
|
|
|
|
|
struct demangled_hash_entry *v;
|
2006-01-31 20:56:55 +01:00
|
|
|
|
*e = v = XCNEW (struct demangled_hash_entry);
|
2002-06-04 09:11:05 +02:00
|
|
|
|
v->key = xstrdup (string);
|
|
|
|
|
}
|
|
|
|
|
return *e;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Stack code. */
|
|
|
|
|
|
|
|
|
|
struct symbol_stack_entry
|
|
|
|
|
{
|
|
|
|
|
symbol *value;
|
|
|
|
|
struct symbol_stack_entry *next;
|
|
|
|
|
};
|
|
|
|
|
struct obstack symbol_stack_obstack;
|
|
|
|
|
struct symbol_stack_entry *symbol_stack;
|
|
|
|
|
|
|
|
|
|
struct file_stack_entry
|
|
|
|
|
{
|
|
|
|
|
file *value;
|
|
|
|
|
struct file_stack_entry *next;
|
|
|
|
|
};
|
|
|
|
|
struct obstack file_stack_obstack;
|
|
|
|
|
struct file_stack_entry *file_stack;
|
|
|
|
|
|
|
|
|
|
static void
|
2003-07-06 14:35:56 +02:00
|
|
|
|
symbol_push (symbol *p)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
2003-07-19 16:47:15 +02:00
|
|
|
|
struct symbol_stack_entry *ep = obstack_alloc
|
1997-08-11 22:23:53 +02:00
|
|
|
|
(&symbol_stack_obstack, sizeof (struct symbol_stack_entry));
|
|
|
|
|
ep->value = p;
|
|
|
|
|
ep->next = symbol_stack;
|
|
|
|
|
symbol_stack = ep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static symbol *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
symbol_pop (void)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
struct symbol_stack_entry *ep = symbol_stack;
|
|
|
|
|
symbol *p;
|
|
|
|
|
if (ep == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
p = ep->value;
|
|
|
|
|
symbol_stack = ep->next;
|
|
|
|
|
obstack_free (&symbol_stack_obstack, ep);
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-07-06 14:35:56 +02:00
|
|
|
|
file_push (file *p)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
struct file_stack_entry *ep;
|
|
|
|
|
|
|
|
|
|
if (p->tweaking)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-07-19 16:47:15 +02:00
|
|
|
|
ep = obstack_alloc
|
1997-08-11 22:23:53 +02:00
|
|
|
|
(&file_stack_obstack, sizeof (struct file_stack_entry));
|
|
|
|
|
ep->value = p;
|
|
|
|
|
ep->next = file_stack;
|
|
|
|
|
file_stack = ep;
|
|
|
|
|
p->tweaking = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static file *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
file_pop (void)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
struct file_stack_entry *ep = file_stack;
|
|
|
|
|
file *p;
|
|
|
|
|
if (ep == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
p = ep->value;
|
|
|
|
|
file_stack = ep->next;
|
|
|
|
|
obstack_free (&file_stack_obstack, ep);
|
|
|
|
|
p->tweaking = 0;
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Other machinery. */
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Initialize the tlink machinery. Called from do_tlink. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static void
|
2003-07-06 14:35:56 +02:00
|
|
|
|
tlink_init (void)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
Makefile.in (tlink.o): Don't depend on toplev.h.
* Makefile.in (tlink.o): Don't depend on toplev.h.
* collect2.c (c_file, o_file, export_file, import_file, ldout,
output_file, nm_file_name, ldd_file_name, strip_file_name,
c_file_name, prefix_list, libexts, is_ctor_dtor, find_a_file,
add_prefix, prefix_from_env, prefix_from_string, do_wait,
fork_execute, maybe_unlink, add_to_list,
extract_init_priority, write_list, dump_list,
dump_prefix_list, write_list_with_asm, write_c_file,
write_c_file_stat, write_c_file_glob, scan_prog_file,
scan_libraries, is_in_list, resolve_lib_name, use_import_list,
ignore_library, extract_string, notice, dump_file, target_machine,
collect_wait, collect_execute, libname, locatelib, aix_std_libs,
read_file, print_load_command): Constify a char*.
(fdopen, error, fatal, fatal_perror): Don't prototype.
(my_strerror): Remove. All callers use xstrerror instead.
(xcalloc, xmalloc, xrealloc, xstrdup, putenv): Remove definitions.
(main): Add prototype. Constify lots of char* ptrs. Change calls
to xcalloc/strcpy/strcat/... to one call to concat.
(main, scan_prog_file, scan_libraries): Use an intermediate
`const char **' to build an argv array.
(mapfile, libselect, libcompare, locatelib): Add prototypes.
* collect2.h (collect_execute, collect_wait, dump_file,
file_exists): Constify a char*.
(ldout, c_file_name, temporary_obstack, permanent_obstack,
temporary_firstobj, vflag, debug): Add extern declarations.
(fancy_abort, error, notice, fatal, fatal_perror): Add prototypes.
* tlink.c: Don't include toplev.h.
(vflag, debug, ldout, c_file_name, temporary_obstack,
permanent_obstack, temporary_firstobj): Don't declare.
(tlink_execute, frob_extension, symbol_hash_lookup,
file_hash_lookup, demangled_hash_lookup, tlink_init, freadsym,
recompile_files, read_repo_files, demangle_new_symbols,
scan_linker_output): Constify a char*.
(symbol_hash_newfunc, file_hash_newfunc, demangled_hash_newfunc,
do_tlink): Mark parameters with ATTRIBUTE_UNUSED.
From-SVN: r29087
1999-09-03 21:13:34 +02:00
|
|
|
|
const char *p;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
2002-06-04 09:11:05 +02:00
|
|
|
|
symbol_table = htab_create (500, hash_string_hash, hash_string_eq,
|
|
|
|
|
NULL);
|
|
|
|
|
file_table = htab_create (500, hash_string_hash, hash_string_eq,
|
|
|
|
|
NULL);
|
|
|
|
|
demangled_table = htab_create (500, hash_string_hash, hash_string_eq,
|
|
|
|
|
NULL);
|
2003-07-06 14:35:56 +02:00
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
obstack_begin (&symbol_stack_obstack, 0);
|
|
|
|
|
obstack_begin (&file_stack_obstack, 0);
|
|
|
|
|
|
|
|
|
|
p = getenv ("TLINK_VERBOSE");
|
|
|
|
|
if (p)
|
|
|
|
|
tlink_verbose = atoi (p);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tlink_verbose = 1;
|
|
|
|
|
if (vflag)
|
|
|
|
|
tlink_verbose = 2;
|
|
|
|
|
if (debug)
|
|
|
|
|
tlink_verbose = 3;
|
|
|
|
|
}
|
2004-08-25 22:51:19 +02:00
|
|
|
|
|
|
|
|
|
getcwd (initial_cwd, sizeof (initial_cwd));
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2005-03-31 16:53:17 +02:00
|
|
|
|
tlink_execute (const char *prog, char **argv, const char *outname,
|
|
|
|
|
const char *errname)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
2005-03-29 21:39:35 +02:00
|
|
|
|
struct pex_obj *pex;
|
|
|
|
|
|
2005-03-31 16:53:17 +02:00
|
|
|
|
pex = collect_execute (prog, argv, outname, errname);
|
2005-03-29 21:39:35 +02:00
|
|
|
|
return collect_wait (prog, pex);
|
2002-05-18 17:16:25 +02:00
|
|
|
|
}
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
static char *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
frob_extension (const char *s, const char *ext)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
* collect2.c (main, write_c_file_stat), gcc.c (translate_options,
process_command, main), gcov.c (open_files, output_data), tlink.c
(frob_extension, scan_linker_output), toplev.c
(file_name_nondirectory): Use strchr () and strrchr () instead of
index () and rindex ().
cp:
* dump.c (dequeue_and_dump), lex.c (interface_strcmp), method.c
(build_overload_value), repo.c (open_repo_file), xref.c
(open_xref_file): Use strchr () and strrchr () instead of index ()
and rindex ().
f:
* com.c (open_include_file, ffecom_open_include_): Use strchr ()
and strrchr () instead of index () and rindex ().
From-SVN: r37206
2000-11-02 20:03:59 +01:00
|
|
|
|
const char *p = strrchr (s, '/');
|
1997-08-11 22:23:53 +02:00
|
|
|
|
if (! p)
|
|
|
|
|
p = s;
|
* collect2.c (main, write_c_file_stat), gcc.c (translate_options,
process_command, main), gcov.c (open_files, output_data), tlink.c
(frob_extension, scan_linker_output), toplev.c
(file_name_nondirectory): Use strchr () and strrchr () instead of
index () and rindex ().
cp:
* dump.c (dequeue_and_dump), lex.c (interface_strcmp), method.c
(build_overload_value), repo.c (open_repo_file), xref.c
(open_xref_file): Use strchr () and strrchr () instead of index ()
and rindex ().
f:
* com.c (open_include_file, ffecom_open_include_): Use strchr ()
and strrchr () instead of index () and rindex ().
From-SVN: r37206
2000-11-02 20:03:59 +01:00
|
|
|
|
p = strrchr (p, '.');
|
1997-08-11 22:23:53 +02:00
|
|
|
|
if (! p)
|
|
|
|
|
p = s + strlen (s);
|
|
|
|
|
|
|
|
|
|
obstack_grow (&temporary_obstack, s, p - s);
|
|
|
|
|
return obstack_copy0 (&temporary_obstack, ext, strlen (ext));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
obstack_fgets (FILE *stream, struct obstack *ob)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
int c;
|
|
|
|
|
while ((c = getc (stream)) != EOF && c != '\n')
|
|
|
|
|
obstack_1grow (ob, c);
|
|
|
|
|
if (obstack_object_size (ob) == 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
obstack_1grow (ob, '\0');
|
libiberty.h (XOBFINISH): New.
libiberty/
2005-06-06 Gabriel Dos Reis <gdr@integrable-solutions.net>
* libiberty.h (XOBFINISH): New.
gcc/
2005-06-06 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-lex.c (lex_string): Use XOBFINISH.
* collect2.c (extract_string, dump_file): Likewise.
* dbxout.c (dbxout_finish_complex_stabs): Likewise.
* gcc.c (init_spec, build_search_list, convert_filename,
set_collect_gcc_options, do_spec_2, do_spec_1, main):
* Likewise.
* genpreds.c (write_predicate_subfunction): Likewise.
* genflags.c (main): Likewise.
* read-rtl.c (mode_attr_index, apply_macro_to_string,
join_c_conditions, read_quoted_string, read_braced_string,
read_rtx_1): Likewise.
* stringpool.c (ggc_alloc_string): Likewise.
* tlink.c (obstack_fgets, recompile_files): Likewise.
From-SVN: r100678
2005-06-06 23:14:31 +02:00
|
|
|
|
return XOBFINISH (ob, char *);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
tfgets (FILE *stream)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
return obstack_fgets (stream, &temporary_obstack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2003-07-06 14:35:56 +02:00
|
|
|
|
pfgets (FILE *stream)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
2002-08-05 00:45:31 +02:00
|
|
|
|
return xstrdup (tfgets (stream));
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Real tlink code. */
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Subroutine of read_repo_file. We are reading the repo file for file F,
|
|
|
|
|
which is coming in on STREAM, and the symbol that comes next in STREAM
|
2002-12-24 09:30:34 +01:00
|
|
|
|
is offered, chosen or provided if CHOSEN is 0, 1 or 2, respectively.
|
1999-01-26 20:34:06 +01:00
|
|
|
|
|
|
|
|
|
XXX "provided" is unimplemented, both here and in the compiler. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static void
|
2003-07-06 14:35:56 +02:00
|
|
|
|
freadsym (FILE *stream, file *f, int chosen)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
symbol *sym;
|
|
|
|
|
|
|
|
|
|
{
|
Makefile.in (tlink.o): Don't depend on toplev.h.
* Makefile.in (tlink.o): Don't depend on toplev.h.
* collect2.c (c_file, o_file, export_file, import_file, ldout,
output_file, nm_file_name, ldd_file_name, strip_file_name,
c_file_name, prefix_list, libexts, is_ctor_dtor, find_a_file,
add_prefix, prefix_from_env, prefix_from_string, do_wait,
fork_execute, maybe_unlink, add_to_list,
extract_init_priority, write_list, dump_list,
dump_prefix_list, write_list_with_asm, write_c_file,
write_c_file_stat, write_c_file_glob, scan_prog_file,
scan_libraries, is_in_list, resolve_lib_name, use_import_list,
ignore_library, extract_string, notice, dump_file, target_machine,
collect_wait, collect_execute, libname, locatelib, aix_std_libs,
read_file, print_load_command): Constify a char*.
(fdopen, error, fatal, fatal_perror): Don't prototype.
(my_strerror): Remove. All callers use xstrerror instead.
(xcalloc, xmalloc, xrealloc, xstrdup, putenv): Remove definitions.
(main): Add prototype. Constify lots of char* ptrs. Change calls
to xcalloc/strcpy/strcat/... to one call to concat.
(main, scan_prog_file, scan_libraries): Use an intermediate
`const char **' to build an argv array.
(mapfile, libselect, libcompare, locatelib): Add prototypes.
* collect2.h (collect_execute, collect_wait, dump_file,
file_exists): Constify a char*.
(ldout, c_file_name, temporary_obstack, permanent_obstack,
temporary_firstobj, vflag, debug): Add extern declarations.
(fancy_abort, error, notice, fatal, fatal_perror): Add prototypes.
* tlink.c: Don't include toplev.h.
(vflag, debug, ldout, c_file_name, temporary_obstack,
permanent_obstack, temporary_firstobj): Don't declare.
(tlink_execute, frob_extension, symbol_hash_lookup,
file_hash_lookup, demangled_hash_lookup, tlink_init, freadsym,
recompile_files, read_repo_files, demangle_new_symbols,
scan_linker_output): Constify a char*.
(symbol_hash_newfunc, file_hash_newfunc, demangled_hash_newfunc,
do_tlink): Mark parameters with ATTRIBUTE_UNUSED.
From-SVN: r29087
1999-09-03 21:13:34 +02:00
|
|
|
|
const char *name = tfgets (stream);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
sym = symbol_hash_lookup (name, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sym->file == NULL)
|
|
|
|
|
{
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* We didn't have this symbol already, so we choose this file. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
symbol_push (sym);
|
|
|
|
|
sym->file = f;
|
|
|
|
|
sym->chosen = chosen;
|
|
|
|
|
}
|
|
|
|
|
else if (chosen)
|
|
|
|
|
{
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* We want this file; cast aside any pretender. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
if (sym->chosen && sym->file != f)
|
|
|
|
|
{
|
|
|
|
|
if (sym->chosen == 1)
|
|
|
|
|
file_push (sym->file);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
file_push (f);
|
|
|
|
|
f = sym->file;
|
|
|
|
|
chosen = sym->chosen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sym->file = f;
|
|
|
|
|
sym->chosen = chosen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Read in the repo file denoted by F, and record all its information. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static void
|
2003-07-06 14:35:56 +02:00
|
|
|
|
read_repo_file (file *f)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
char c;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
FILE *stream = fopen (f->key, "r");
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
if (tlink_verbose >= 2)
|
2002-06-04 09:11:05 +02:00
|
|
|
|
fprintf (stderr, _("collect: reading %s\n"), f->key);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
while (fscanf (stream, "%c ", &c) == 1)
|
|
|
|
|
{
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case 'A':
|
|
|
|
|
f->args = pfgets (stream);
|
|
|
|
|
break;
|
|
|
|
|
case 'D':
|
|
|
|
|
f->dir = pfgets (stream);
|
|
|
|
|
break;
|
|
|
|
|
case 'M':
|
|
|
|
|
f->main = pfgets (stream);
|
|
|
|
|
break;
|
|
|
|
|
case 'P':
|
|
|
|
|
freadsym (stream, f, 2);
|
|
|
|
|
break;
|
|
|
|
|
case 'C':
|
|
|
|
|
freadsym (stream, f, 1);
|
|
|
|
|
break;
|
|
|
|
|
case 'O':
|
|
|
|
|
freadsym (stream, f, 0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
obstack_free (&temporary_obstack, temporary_firstobj);
|
|
|
|
|
}
|
|
|
|
|
fclose (stream);
|
|
|
|
|
if (f->args == NULL)
|
|
|
|
|
f->args = getenv ("COLLECT_GCC_OPTIONS");
|
|
|
|
|
if (f->dir == NULL)
|
|
|
|
|
f->dir = ".";
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* We might want to modify LINE, which is a symbol line from file F. We do
|
|
|
|
|
this if either we saw an error message referring to the symbol in
|
|
|
|
|
question, or we have already allocated the symbol to another file and
|
|
|
|
|
this one wants to emit it as well. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static void
|
2003-07-06 14:35:56 +02:00
|
|
|
|
maybe_tweak (char *line, file *f)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
symbol *sym = symbol_hash_lookup (line + 2, false);
|
|
|
|
|
|
|
|
|
|
if ((sym->file == f && sym->tweaking)
|
|
|
|
|
|| (sym->file != f && line[0] == 'C'))
|
|
|
|
|
{
|
|
|
|
|
sym->tweaking = 0;
|
|
|
|
|
sym->tweaked = 1;
|
|
|
|
|
|
|
|
|
|
if (line[0] == 'O')
|
|
|
|
|
line[0] = 'C';
|
|
|
|
|
else
|
|
|
|
|
line[0] = 'O';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Update the repo files for each of the object files we have adjusted and
|
2004-08-25 22:51:19 +02:00
|
|
|
|
recompile. */
|
1999-01-26 20:34:06 +01:00
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static int
|
2003-07-06 14:35:56 +02:00
|
|
|
|
recompile_files (void)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
file *f;
|
|
|
|
|
|
2003-04-22 14:44:06 +02:00
|
|
|
|
putenv (xstrdup ("COMPILER_PATH="));
|
|
|
|
|
putenv (xstrdup ("LIBRARY_PATH="));
|
2002-05-18 17:16:25 +02:00
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
while ((f = file_pop ()) != NULL)
|
|
|
|
|
{
|
2004-08-25 22:51:19 +02:00
|
|
|
|
char *line;
|
|
|
|
|
const char *p, *q;
|
|
|
|
|
char **argv;
|
|
|
|
|
struct obstack arg_stack;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
FILE *stream = fopen (f->key, "r");
|
|
|
|
|
const char *const outname = frob_extension (f->key, ".rnw");
|
1997-08-11 22:23:53 +02:00
|
|
|
|
FILE *output = fopen (outname, "w");
|
|
|
|
|
|
|
|
|
|
while ((line = tfgets (stream)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
switch (line[0])
|
|
|
|
|
{
|
|
|
|
|
case 'C':
|
|
|
|
|
case 'O':
|
|
|
|
|
maybe_tweak (line, f);
|
|
|
|
|
}
|
|
|
|
|
fprintf (output, "%s\n", line);
|
|
|
|
|
}
|
|
|
|
|
fclose (stream);
|
|
|
|
|
fclose (output);
|
2005-03-30 11:58:48 +02:00
|
|
|
|
/* On Windows "rename" returns -1 and sets ERRNO to EACCESS if
|
|
|
|
|
the new file name already exists. Therefore, we explicitly
|
|
|
|
|
remove the old file first. */
|
|
|
|
|
if (remove (f->key) == -1)
|
|
|
|
|
fatal_perror ("removing .rpo file");
|
|
|
|
|
if (rename (outname, f->key) == -1)
|
|
|
|
|
fatal_perror ("renaming .rpo file");
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
2004-07-29 19:59:31 +02:00
|
|
|
|
if (!f->args)
|
|
|
|
|
{
|
builtins.c, [...]: Avoid "`" as left quote, using "'" or %q, %< and %> as appropriate.
* builtins.c, c-common.c, c-decl.c, c-format.c, c-format.h,
c-parse.in, c-pch.c, c-pragma.c, collect2.c, final.c, gcc.c,
gcov.c, opts.c, pretty-print.h, protoize.c, reg-stack.c, rtl.c,
tlink.c, config/alpha/alpha.c, config/arc/arc.c, config/arm/arm.c,
config/avr/avr.c, config/c4x/c4x.c, config/darwin.c,
config/frv/frv.c, config/h8300/h8300.c, config/i386/i386.c,
config/i386/winnt.c, config/ia64/ia64.c, config/ip2k/ip2k.c,
config/iq2000/iq2000.c, config/m32r/m32r.c,
config/m68hc11/m68hc11.c, config/m68k/m68k.c, config/m68k/m68k.h,
config/mcore/mcore.c, config/mips/mips.c, config/mmix/mmix.c,
config/ns32k/ns32k.c, config/rs6000/host-darwin.c,
config/rs6000/rs6000.c, config/s390/s390.c, config/sh/sh.c,
config/sh/symbian.c, config/stormy16/stormy16.c,
config/v850/v850.c: Avoid "`" as left quote, using "'" or %q, %<
and %> as appropriate. Use %' as apostrophe in diagnostics where
applicable. Use %< and %> in place of '' quotes where applicable.
Use %qs in place of %<%s%>. Consistently quote __builtin function
names.
ada:
* misc.c (gnat_handle_option): Use %< and %> for quoting in
warning message.
cp:
* call.c, class.c, decl.c, decl2.c, error.c, mangle.c, parser.c,
pt.c, search.c, semantics.c, typeck.c: Use %q, %< and %> for
quoting in diagnostics.
* parser.c (cp_parser_sizeof_operand): Use '' instead of `' for
quoting in printf format.
* decl.c (duplicate_decls, start_decl): Use %qD instead of
unquoted %D.
objc:
* objc-act.c: Use %q, %< and %> for quoting in diagnostics.
testsuite:
* gcc.dg/builtin-prefetch-1.c: Adjust expected messages.
From-SVN: r90337
2004-11-09 11:13:30 +01:00
|
|
|
|
error ("repository file '%s' does not contain command-line "
|
2004-07-29 19:59:31 +02:00
|
|
|
|
"arguments", f->key);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2004-08-25 22:51:19 +02:00
|
|
|
|
|
|
|
|
|
/* Build a null-terminated argv array suitable for
|
|
|
|
|
tlink_execute(). Manipulate arguments on the arg_stack while
|
|
|
|
|
building argv on the temporary_obstack. */
|
|
|
|
|
|
|
|
|
|
obstack_init (&arg_stack);
|
|
|
|
|
obstack_ptr_grow (&temporary_obstack, c_file_name);
|
|
|
|
|
|
|
|
|
|
for (p = f->args; *p != '\0'; p = q + 1)
|
|
|
|
|
{
|
|
|
|
|
/* Arguments are delimited by single-quotes. Find the
|
|
|
|
|
opening quote. */
|
|
|
|
|
p = strchr (p, '\'');
|
|
|
|
|
if (!p)
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
/* Find the closing quote. */
|
|
|
|
|
q = strchr (p + 1, '\'');
|
|
|
|
|
if (!q)
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
obstack_grow (&arg_stack, p + 1, q - (p + 1));
|
|
|
|
|
|
|
|
|
|
/* Replace '\'' with '. This is how set_collect_gcc_options
|
|
|
|
|
encodes a single-quote. */
|
|
|
|
|
while (q[1] == '\\' && q[2] == '\'' && q[3] == '\'')
|
|
|
|
|
{
|
|
|
|
|
const char *r;
|
|
|
|
|
|
|
|
|
|
r = strchr (q + 4, '\'');
|
|
|
|
|
if (!r)
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
obstack_grow (&arg_stack, q + 3, r - (q + 3));
|
|
|
|
|
q = r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obstack_1grow (&arg_stack, '\0');
|
|
|
|
|
obstack_ptr_grow (&temporary_obstack, obstack_finish (&arg_stack));
|
|
|
|
|
}
|
|
|
|
|
done:
|
|
|
|
|
obstack_ptr_grow (&temporary_obstack, f->main);
|
|
|
|
|
obstack_ptr_grow (&temporary_obstack, NULL);
|
libiberty.h (XOBFINISH): New.
libiberty/
2005-06-06 Gabriel Dos Reis <gdr@integrable-solutions.net>
* libiberty.h (XOBFINISH): New.
gcc/
2005-06-06 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-lex.c (lex_string): Use XOBFINISH.
* collect2.c (extract_string, dump_file): Likewise.
* dbxout.c (dbxout_finish_complex_stabs): Likewise.
* gcc.c (init_spec, build_search_list, convert_filename,
set_collect_gcc_options, do_spec_2, do_spec_1, main):
* Likewise.
* genpreds.c (write_predicate_subfunction): Likewise.
* genflags.c (main): Likewise.
* read-rtl.c (mode_attr_index, apply_macro_to_string,
join_c_conditions, read_quoted_string, read_braced_string,
read_rtx_1): Likewise.
* stringpool.c (ggc_alloc_string): Likewise.
* tlink.c (obstack_fgets, recompile_files): Likewise.
From-SVN: r100678
2005-06-06 23:14:31 +02:00
|
|
|
|
argv = XOBFINISH (&temporary_obstack, char **);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
if (tlink_verbose)
|
2000-06-29 01:46:27 +02:00
|
|
|
|
fprintf (stderr, _("collect: recompiling %s\n"), f->main);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
2004-08-25 22:51:19 +02:00
|
|
|
|
if (chdir (f->dir) != 0
|
2005-03-31 16:53:17 +02:00
|
|
|
|
|| tlink_execute (c_file_name, argv, NULL, NULL) != 0
|
2004-08-25 22:51:19 +02:00
|
|
|
|
|| chdir (initial_cwd) != 0)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
read_repo_file (f);
|
|
|
|
|
|
2004-08-25 22:51:19 +02:00
|
|
|
|
obstack_free (&arg_stack, NULL);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
obstack_free (&temporary_obstack, temporary_firstobj);
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* The first phase of processing: determine which object files have
|
|
|
|
|
.rpo files associated with them, and read in the information. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static int
|
2003-07-06 14:35:56 +02:00
|
|
|
|
read_repo_files (char **object_lst)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
char **object = object_lst;
|
|
|
|
|
|
|
|
|
|
for (; *object; object++)
|
|
|
|
|
{
|
2000-04-06 23:03:45 +02:00
|
|
|
|
const char *p;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
file *f;
|
|
|
|
|
|
2000-04-06 23:03:45 +02:00
|
|
|
|
/* Don't bother trying for ld flags. */
|
|
|
|
|
if (*object[0] == '-')
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
p = frob_extension (*object, ".rpo");
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
if (! file_exists (p))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
f = file_hash_lookup (p);
|
|
|
|
|
|
|
|
|
|
read_repo_file (f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file_stack != NULL && ! recompile_files ())
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return (symbol_stack != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Add the demangled forms of any new symbols to the hash table. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static void
|
2003-07-06 14:35:56 +02:00
|
|
|
|
demangle_new_symbols (void)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
symbol *sym;
|
|
|
|
|
|
|
|
|
|
while ((sym = symbol_pop ()) != NULL)
|
|
|
|
|
{
|
|
|
|
|
demangled *dem;
|
2002-06-04 09:11:05 +02:00
|
|
|
|
const char *p = cplus_demangle (sym->key, DMGL_PARAMS | DMGL_ANSI);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
if (! p)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
dem = demangled_hash_lookup (p, true);
|
2002-06-04 09:11:05 +02:00
|
|
|
|
dem->mangled = sym->key;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Step through the output of the linker, in the file named FNAME, and
|
|
|
|
|
adjust the settings for each symbol encountered. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
static int
|
2003-07-06 14:35:56 +02:00
|
|
|
|
scan_linker_output (const char *fname)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
|
|
|
|
FILE *stream = fopen (fname, "r");
|
|
|
|
|
char *line;
|
2007-02-24 07:22:12 +01:00
|
|
|
|
int skip_next_in_line = 0;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
while ((line = tfgets (stream)) != NULL)
|
|
|
|
|
{
|
|
|
|
|
char *p = line, *q;
|
|
|
|
|
symbol *sym;
|
|
|
|
|
int end;
|
2007-02-24 01:30:30 +01:00
|
|
|
|
int ok = 0;
|
|
|
|
|
|
2007-02-24 07:22:12 +01:00
|
|
|
|
/* On darwin9, we might have to skip " in " lines as well. */
|
|
|
|
|
if (skip_next_in_line
|
|
|
|
|
&& strstr (p, " in "))
|
2007-02-24 01:53:39 +01:00
|
|
|
|
continue;
|
2007-02-24 07:22:12 +01:00
|
|
|
|
skip_next_in_line = 0;
|
2002-05-18 17:16:25 +02:00
|
|
|
|
|
2002-11-16 19:33:29 +01:00
|
|
|
|
while (*p && ISSPACE ((unsigned char) *p))
|
1997-08-11 22:23:53 +02:00
|
|
|
|
++p;
|
|
|
|
|
|
|
|
|
|
if (! *p)
|
|
|
|
|
continue;
|
|
|
|
|
|
2002-11-16 19:33:29 +01:00
|
|
|
|
for (q = p; *q && ! ISSPACE ((unsigned char) *q); ++q)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
/* Try the first word on the line. */
|
|
|
|
|
if (*p == '.')
|
|
|
|
|
++p;
|
2002-09-11 21:58:02 +02:00
|
|
|
|
if (!strncmp (p, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX)))
|
|
|
|
|
p += strlen (USER_LABEL_PREFIX);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
end = ! *q;
|
|
|
|
|
*q = 0;
|
|
|
|
|
sym = symbol_hash_lookup (p, false);
|
|
|
|
|
|
2000-07-18 02:15:46 +02:00
|
|
|
|
/* Some SVR4 linkers produce messages like
|
|
|
|
|
ld: 0711-317 ERROR: Undefined symbol: .g__t3foo1Zi
|
|
|
|
|
*/
|
2002-11-16 19:33:29 +01:00
|
|
|
|
if (! sym && ! end && strstr (q + 1, "Undefined symbol: "))
|
2000-07-18 02:15:46 +02:00
|
|
|
|
{
|
2002-11-16 19:33:29 +01:00
|
|
|
|
char *p = strrchr (q + 1, ' ');
|
2000-07-18 02:15:46 +02:00
|
|
|
|
p++;
|
|
|
|
|
if (*p == '.')
|
|
|
|
|
p++;
|
2002-09-11 21:58:02 +02:00
|
|
|
|
if (!strncmp (p, USER_LABEL_PREFIX, strlen (USER_LABEL_PREFIX)))
|
|
|
|
|
p += strlen (USER_LABEL_PREFIX);
|
2000-07-18 02:15:46 +02:00
|
|
|
|
sym = symbol_hash_lookup (p, false);
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
if (! sym && ! end)
|
1998-10-04 21:37:42 +02:00
|
|
|
|
/* Try a mangled name in quotes. */
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
2002-11-16 19:33:29 +01:00
|
|
|
|
const char *oldq = q + 1;
|
1997-08-11 22:23:53 +02:00
|
|
|
|
demangled *dem = 0;
|
|
|
|
|
q = 0;
|
|
|
|
|
|
2007-02-24 07:22:12 +01:00
|
|
|
|
/* On darwin9, we look for "foo" referenced from:\n\(.* in .*\n\)* */
|
2007-02-24 01:30:30 +01:00
|
|
|
|
if (strcmp (oldq, "referenced from:") == 0)
|
|
|
|
|
{
|
|
|
|
|
/* We have to remember that we found a symbol to tweak. */
|
|
|
|
|
ok = 1;
|
|
|
|
|
|
2007-02-24 07:22:12 +01:00
|
|
|
|
/* We actually want to start from the first word on the
|
|
|
|
|
line. */
|
2007-02-24 01:30:30 +01:00
|
|
|
|
oldq = p;
|
|
|
|
|
|
2007-02-24 07:22:12 +01:00
|
|
|
|
/* Since the format is multiline, we have to skip
|
|
|
|
|
following lines with " in ". */
|
|
|
|
|
skip_next_in_line = 1;
|
2007-02-24 01:30:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
1998-10-04 21:37:42 +02:00
|
|
|
|
/* First try `GNU style'. */
|
* collect2.c (main, write_c_file_stat), gcc.c (translate_options,
process_command, main), gcov.c (open_files, output_data), tlink.c
(frob_extension, scan_linker_output), toplev.c
(file_name_nondirectory): Use strchr () and strrchr () instead of
index () and rindex ().
cp:
* dump.c (dequeue_and_dump), lex.c (interface_strcmp), method.c
(build_overload_value), repo.c (open_repo_file), xref.c
(open_xref_file): Use strchr () and strrchr () instead of index ()
and rindex ().
f:
* com.c (open_include_file, ffecom_open_include_): Use strchr ()
and strrchr () instead of index () and rindex ().
From-SVN: r37206
2000-11-02 20:03:59 +01:00
|
|
|
|
p = strchr (oldq, '`');
|
1998-10-04 21:37:42 +02:00
|
|
|
|
if (p)
|
* collect2.c (main, write_c_file_stat), gcc.c (translate_options,
process_command, main), gcov.c (open_files, output_data), tlink.c
(frob_extension, scan_linker_output), toplev.c
(file_name_nondirectory): Use strchr () and strrchr () instead of
index () and rindex ().
cp:
* dump.c (dequeue_and_dump), lex.c (interface_strcmp), method.c
(build_overload_value), repo.c (open_repo_file), xref.c
(open_xref_file): Use strchr () and strrchr () instead of index ()
and rindex ().
f:
* com.c (open_include_file, ffecom_open_include_): Use strchr ()
and strrchr () instead of index () and rindex ().
From-SVN: r37206
2000-11-02 20:03:59 +01:00
|
|
|
|
p++, q = strchr (p, '\'');
|
1998-10-04 21:37:42 +02:00
|
|
|
|
/* Then try "double quotes". */
|
* collect2.c (main, write_c_file_stat), gcc.c (translate_options,
process_command, main), gcov.c (open_files, output_data), tlink.c
(frob_extension, scan_linker_output), toplev.c
(file_name_nondirectory): Use strchr () and strrchr () instead of
index () and rindex ().
cp:
* dump.c (dequeue_and_dump), lex.c (interface_strcmp), method.c
(build_overload_value), repo.c (open_repo_file), xref.c
(open_xref_file): Use strchr () and strrchr () instead of index ()
and rindex ().
f:
* com.c (open_include_file, ffecom_open_include_): Use strchr ()
and strrchr () instead of index () and rindex ().
From-SVN: r37206
2000-11-02 20:03:59 +01:00
|
|
|
|
else if (p = strchr (oldq, '"'), p)
|
|
|
|
|
p++, q = strchr (p, '"');
|
2003-05-23 20:23:13 +02:00
|
|
|
|
else {
|
|
|
|
|
/* Then try entire line. */
|
|
|
|
|
q = strchr (oldq, 0);
|
|
|
|
|
if (q != oldq)
|
2003-05-23 22:42:41 +02:00
|
|
|
|
p = (char *)oldq;
|
2003-05-23 20:23:13 +02:00
|
|
|
|
}
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
1999-12-15 10:37:48 +01:00
|
|
|
|
if (p)
|
2003-02-26 06:21:26 +01:00
|
|
|
|
{
|
|
|
|
|
/* Don't let the strstr's below see the demangled name; we
|
|
|
|
|
might get spurious matches. */
|
|
|
|
|
p[-1] = '\0';
|
|
|
|
|
|
|
|
|
|
/* powerpc64-linux references .foo when calling function foo. */
|
|
|
|
|
if (*p == '.')
|
|
|
|
|
p++;
|
|
|
|
|
}
|
1999-12-15 10:37:48 +01:00
|
|
|
|
|
1999-09-17 20:35:31 +02:00
|
|
|
|
/* We need to check for certain error keywords here, or we would
|
|
|
|
|
mistakenly use GNU ld's "In function `foo':" message. */
|
2007-02-24 01:30:30 +01:00
|
|
|
|
if (q && (ok
|
|
|
|
|
|| strstr (oldq, "ndefined")
|
1999-09-17 20:54:29 +02:00
|
|
|
|
|| strstr (oldq, "nresolved")
|
2001-08-14 17:01:48 +02:00
|
|
|
|
|| strstr (oldq, "nsatisfied")
|
1999-09-17 20:35:31 +02:00
|
|
|
|
|| strstr (oldq, "ultiple")))
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
1998-10-04 21:37:42 +02:00
|
|
|
|
*q = 0;
|
|
|
|
|
dem = demangled_hash_lookup (p, false);
|
|
|
|
|
if (dem)
|
|
|
|
|
sym = symbol_hash_lookup (dem->mangled, false);
|
|
|
|
|
else
|
2002-05-18 17:16:25 +02:00
|
|
|
|
{
|
2002-09-11 21:58:02 +02:00
|
|
|
|
if (!strncmp (p, USER_LABEL_PREFIX,
|
|
|
|
|
strlen (USER_LABEL_PREFIX)))
|
|
|
|
|
p += strlen (USER_LABEL_PREFIX);
|
1999-09-03 18:14:54 +02:00
|
|
|
|
sym = symbol_hash_lookup (p, false);
|
|
|
|
|
}
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sym && sym->tweaked)
|
1998-01-27 10:23:08 +01:00
|
|
|
|
{
|
builtins.c, [...]: Avoid "`" as left quote, using "'" or %q, %< and %> as appropriate.
* builtins.c, c-common.c, c-decl.c, c-format.c, c-format.h,
c-parse.in, c-pch.c, c-pragma.c, collect2.c, final.c, gcc.c,
gcov.c, opts.c, pretty-print.h, protoize.c, reg-stack.c, rtl.c,
tlink.c, config/alpha/alpha.c, config/arc/arc.c, config/arm/arm.c,
config/avr/avr.c, config/c4x/c4x.c, config/darwin.c,
config/frv/frv.c, config/h8300/h8300.c, config/i386/i386.c,
config/i386/winnt.c, config/ia64/ia64.c, config/ip2k/ip2k.c,
config/iq2000/iq2000.c, config/m32r/m32r.c,
config/m68hc11/m68hc11.c, config/m68k/m68k.c, config/m68k/m68k.h,
config/mcore/mcore.c, config/mips/mips.c, config/mmix/mmix.c,
config/ns32k/ns32k.c, config/rs6000/host-darwin.c,
config/rs6000/rs6000.c, config/s390/s390.c, config/sh/sh.c,
config/sh/symbian.c, config/stormy16/stormy16.c,
config/v850/v850.c: Avoid "`" as left quote, using "'" or %q, %<
and %> as appropriate. Use %' as apostrophe in diagnostics where
applicable. Use %< and %> in place of '' quotes where applicable.
Use %qs in place of %<%s%>. Consistently quote __builtin function
names.
ada:
* misc.c (gnat_handle_option): Use %< and %> for quoting in
warning message.
cp:
* call.c, class.c, decl.c, decl2.c, error.c, mangle.c, parser.c,
pt.c, search.c, semantics.c, typeck.c: Use %q, %< and %> for
quoting in diagnostics.
* parser.c (cp_parser_sizeof_operand): Use '' instead of `' for
quoting in printf format.
* decl.c (duplicate_decls, start_decl): Use %qD instead of
unquoted %D.
objc:
* objc-act.c: Use %q, %< and %> for quoting in diagnostics.
testsuite:
* gcc.dg/builtin-prefetch-1.c: Adjust expected messages.
From-SVN: r90337
2004-11-09 11:13:30 +01:00
|
|
|
|
error ("'%s' was assigned to '%s', but was not defined "
|
2004-07-29 19:59:31 +02:00
|
|
|
|
"during recompilation, or vice versa",
|
|
|
|
|
sym->key, sym->file->key);
|
1998-01-27 10:23:08 +01:00
|
|
|
|
fclose (stream);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1997-08-11 22:23:53 +02:00
|
|
|
|
if (sym && !sym->tweaking)
|
|
|
|
|
{
|
|
|
|
|
if (tlink_verbose >= 2)
|
2000-06-29 01:46:27 +02:00
|
|
|
|
fprintf (stderr, _("collect: tweaking %s in %s\n"),
|
2002-06-04 09:11:05 +02:00
|
|
|
|
sym->key, sym->file->key);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
sym->tweaking = 1;
|
|
|
|
|
file_push (sym->file);
|
|
|
|
|
}
|
2002-05-18 17:16:25 +02:00
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
obstack_free (&temporary_obstack, temporary_firstobj);
|
|
|
|
|
}
|
|
|
|
|
|
1998-01-27 10:23:08 +01:00
|
|
|
|
fclose (stream);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
return (file_stack != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-26 20:34:06 +01:00
|
|
|
|
/* Entry point for tlink. Called from main in collect2.c.
|
|
|
|
|
|
|
|
|
|
Iteratively try to provide definitions for all the unresolved symbols
|
|
|
|
|
mentioned in the linker error messages.
|
|
|
|
|
|
|
|
|
|
LD_ARGV is an array of arguments for the linker.
|
|
|
|
|
OBJECT_LST is an array of object files that we may be able to recompile
|
|
|
|
|
to provide missing definitions. Currently ignored. */
|
|
|
|
|
|
1997-08-11 22:23:53 +02:00
|
|
|
|
void
|
2003-07-06 14:35:56 +02:00
|
|
|
|
do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED)
|
1997-08-11 22:23:53 +02:00
|
|
|
|
{
|
2005-03-31 16:53:17 +02:00
|
|
|
|
int exit = tlink_execute ("ld", ld_argv, ldout, lderrout);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
|
|
|
|
|
tlink_init ();
|
|
|
|
|
|
|
|
|
|
if (exit)
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
/* Until collect does a better job of figuring out which are object
|
|
|
|
|
files, assume that everything on the command line could be. */
|
|
|
|
|
if (read_repo_files (ld_argv))
|
|
|
|
|
while (exit && i++ < MAX_ITERATIONS)
|
|
|
|
|
{
|
|
|
|
|
if (tlink_verbose >= 3)
|
2005-03-31 16:53:17 +02:00
|
|
|
|
{
|
|
|
|
|
dump_file (ldout, stdout);
|
|
|
|
|
dump_file (lderrout, stderr);
|
|
|
|
|
}
|
1997-08-11 22:23:53 +02:00
|
|
|
|
demangle_new_symbols ();
|
2005-03-31 16:53:17 +02:00
|
|
|
|
if (! scan_linker_output (ldout)
|
|
|
|
|
&& ! scan_linker_output (lderrout))
|
1997-08-11 22:23:53 +02:00
|
|
|
|
break;
|
|
|
|
|
if (! recompile_files ())
|
|
|
|
|
break;
|
|
|
|
|
if (tlink_verbose)
|
2000-06-29 01:46:27 +02:00
|
|
|
|
fprintf (stderr, _("collect: relinking\n"));
|
2005-03-31 16:53:17 +02:00
|
|
|
|
exit = tlink_execute ("ld", ld_argv, ldout, lderrout);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-31 16:53:17 +02:00
|
|
|
|
dump_file (ldout, stdout);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
unlink (ldout);
|
2005-03-31 16:53:17 +02:00
|
|
|
|
dump_file (lderrout, stderr);
|
|
|
|
|
unlink (lderrout);
|
1997-08-11 22:23:53 +02:00
|
|
|
|
if (exit)
|
|
|
|
|
{
|
|
|
|
|
error ("ld returned %d exit status", exit);
|
|
|
|
|
collect_exit (exit);
|
|
|
|
|
}
|
|
|
|
|
}
|