2003-06-03  H.J. Lu <hongjiu.lu@intel.com>

	* elflink.h (elf_link_input_bfd): Call linker error_handler
	for discarded definitions.

include/

2003-06-03  H.J. Lu <hongjiu.lu@intel.com>

	* bfdlink.h (LD_DEFINITION_IN_DISCARDED_SECTION): New.

ld/

2003-06-03  H.J. Lu <hongjiu.lu@intel.com>

	* ldmisc.c: Include "bfdlink.h".
	(error_handler): Handle LD_DEFINITION_IN_DISCARDED_SECTION
	and -LD_DEFINITION_IN_DISCARDED_SECTION.

	* Makefile.am: Rebuild dependency.
	* Makefile.in: Regenerated.

ld/testsuite/

2003-06-03  H.J. Lu <hongjiu.lu@intel.com>

	* ld-discard/extern.d: Updated.
	* ld-discard/start.d: Likewise.
	* ld-discard/static.d: Likewise.
This commit is contained in:
H.J. Lu
2003-06-03 18:15:05 +00:00
parent a3b6428fe7
commit 6f6f27f842
12 changed files with 111 additions and 37 deletions

View File

@ -22,6 +22,7 @@
02111-1307, USA. */
#include "bfd.h"
#include "bfdlink.h"
#include "sysdep.h"
#include "libiberty.h"
#include "demangle.h"
@ -508,12 +509,63 @@ ld_abort (file, line, fn)
}
bfd_boolean
error_handler VPARAMS ((int id ATTRIBUTE_UNUSED, const char *fmt, ...))
error_handler VPARAMS ((int id, const char *fmt, ...))
{
VA_OPEN (arg, fmt);
VA_FIXEDARG (arg, const char *, fmt);
va_start (arg, fmt);
switch (id)
{
default:
break;
/* We can be called with
error_handler (-LD_DEFINITION_IN_DISCARDED_SECTION, "", 0);
to make this error non-fatal and
error_handler (-LD_DEFINITION_IN_DISCARDED_SECTION, "", 1);
to make this error fatal. */
case -LD_DEFINITION_IN_DISCARDED_SECTION:
case LD_DEFINITION_IN_DISCARDED_SECTION:
{
static struct bfd_hash_table *hash;
static int fatal = 1;
const char *name;
if (id == -LD_DEFINITION_IN_DISCARDED_SECTION)
{
fatal = va_arg (arg, int);
goto out;
}
name = va_arg (arg, const char *);
/* Only warn once about a particular undefined symbol. */
if (hash == NULL)
{
hash = ((struct bfd_hash_table *)
xmalloc (sizeof (struct bfd_hash_table)));
if (! bfd_hash_table_init (hash, bfd_hash_newfunc))
einfo (_("%F%P: bfd_hash_table_init failed: %E\n"));
}
if (bfd_hash_lookup (hash, name, FALSE, FALSE) != NULL)
goto out;
if (bfd_hash_lookup (hash, name, TRUE, TRUE) == NULL)
einfo (_("%F%P: bfd_hash_lookup failed: %E\n"));
if (fatal)
config.make_executable = FALSE;
}
break;
}
vfinfo (stderr, fmt, arg);
out:
VA_CLOSE (arg);
return TRUE;
}