/* Main program of GNU linker.
- Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 1999
+ Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
Written by Steve Chamberlain steve@cygnus.com
#include "libiberty.h"
#include "progress.h"
#include "bfdlink.h"
+#include "filenames.h"
#include "ld.h"
#include "ldmain.h"
#include "ldgram.h"
#include "ldexp.h"
#include "ldlang.h"
-#include "ldemul.h"
#include "ldlex.h"
#include "ldfile.h"
+#include "ldemul.h"
#include "ldctor.h"
/* Somewhere above, sys/stat.h got included . . . . */
static void warning_find_reloc PARAMS ((bfd *, asection *, PTR));
static boolean undefined_symbol PARAMS ((struct bfd_link_info *,
const char *, bfd *,
- asection *, bfd_vma));
+ asection *, bfd_vma, boolean));
static boolean reloc_overflow PARAMS ((struct bfd_link_info *, const char *,
const char *, bfd_vma,
bfd *, asection *, bfd_vma));
config.build_constructors = true;
config.dynamic_link = false;
config.has_shared = false;
+ config.split_by_reloc = (unsigned) -1;
+ config.split_by_file = (bfd_size_type) -1;
command_line.force_common_definition = false;
command_line.interpreter = NULL;
command_line.rpath = NULL;
link_info.callbacks = &link_callbacks;
link_info.relocateable = false;
+ link_info.emitrelocations = false;
link_info.shared = false;
link_info.symbolic = false;
link_info.static_link = false;
and _fini symbols. We are compatible. */
link_info.init_function = "_init";
link_info.fini_function = "_fini";
+ link_info.new_dtags = false;
+ link_info.flags = (bfd_vma) 0;
+ link_info.flags_1 = (bfd_vma) 0;
ldfile_add_arch ("");
/* Print error messages for any missing symbols, for any warning
symbols, and possibly multiple definitions */
-
- if (config.text_read_only)
+ if (! link_info.relocateable)
{
- /* Look for a text section and mark the readonly attribute in it */
- asection *found = bfd_get_section_by_name (output_bfd, ".text");
-
+ /* Look for a text section and switch the readonly attribute in it. */
+ asection * found = bfd_get_section_by_name (output_bfd, ".text");
+
if (found != (asection *) NULL)
{
- found->flags |= SEC_READONLY;
+ if (config.text_read_only)
+ found->flags |= SEC_READONLY;
+ else
+ found->flags &= ~SEC_READONLY;
}
}
/* Look for "ldscripts" in the dir where our binary is. */
end = strrchr (program_name, '/');
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ {
+ /* We could have \foo\bar, or /foo\bar. */
+ char *bslash = strrchr (program_name, '\\');
+ if (end == NULL || (bslash != NULL && bslash > end))
+ end = bslash;
+ }
+#endif
if (end == NULL)
{
/*ARGSUSED*/
static boolean
-undefined_symbol (info, name, abfd, section, address)
+undefined_symbol (info, name, abfd, section, address, fatal)
struct bfd_link_info *info ATTRIBUTE_UNUSED;
const char *name;
bfd *abfd;
asection *section;
bfd_vma address;
+ boolean fatal ATTRIBUTE_UNUSED;
{
static char *error_name;
static unsigned int error_count;
if (section != NULL)
{
if (error_count < MAX_ERRORS_IN_A_ROW)
- einfo (_("%X%C: undefined reference to `%T'\n"),
- abfd, section, address, name);
+ {
+ einfo (_("%C: undefined reference to `%T'\n"),
+ abfd, section, address, name);
+ if (fatal)
+ einfo ("%X");
+ }
else if (error_count == MAX_ERRORS_IN_A_ROW)
einfo (_("%D: more undefined references to `%T' follow\n"),
abfd, section, address, name);
else
{
if (error_count < MAX_ERRORS_IN_A_ROW)
- einfo (_("%X%B: undefined reference to `%T'\n"),
- abfd, name);
+ {
+ einfo (_("%B: undefined reference to `%T'\n"),
+ abfd, name);
+ if (fatal)
+ einfo ("%X");
+ }
else if (error_count == MAX_ERRORS_IN_A_ROW)
einfo (_("%B: more undefined references to `%T' follow\n"),
abfd, name);