/* Routines to help build PEI-format DLLs (Win32 etc)
- Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Written by DJ Delorie <dj@cygnus.com>
This file is part of GLD, the Gnu Linker.
#include "sysdep.h"
#include "bfdlink.h"
#include "libiberty.h"
+#include "safe-ctype.h"
#include <time.h>
-#include <ctype.h>
#include "ld.h"
#include "ldexp.h"
{ "crt0.o", 6 },
{ "crt1.o", 6 },
{ "crt2.o", 6 },
+ { "dllcrt1.o", 9 },
+ { "dllcrt2.o", 9 },
+ { "gcrt0.o", 7 },
+ { "gcrt1.o", 7 },
+ { "gcrt2.o", 7 },
{ NULL, 0 }
};
static void quoteput PARAMS ((char *, FILE *, int));
static asection *quick_section PARAMS ((bfd *, const char *, int, int));
static void quick_symbol
- PARAMS ((bfd *, char *, char *, char *, asection *, int, int));
+ PARAMS ((bfd *, const char *, const char *, const char *,
+ asection *, int, int));
static void quick_reloc PARAMS ((bfd *, int, int, int));
static bfd *make_head PARAMS ((bfd *));
static bfd *make_tail PARAMS ((bfd *));
static bfd *make_one PARAMS ((def_file_export *, bfd *));
-static bfd *make_singleton_name_thunk PARAMS ((char *, bfd *));
+static bfd *make_singleton_name_thunk PARAMS ((const char *, bfd *));
static char *make_import_fixup_mark PARAMS ((arelent *));
-static bfd *make_import_fixup_entry PARAMS ((char *, char *, char *, bfd *));
+static bfd *make_import_fixup_entry
+ PARAMS ((const char *, const char *, const char *, bfd *));
static unsigned int pe_get16 PARAMS ((bfd *, int));
static unsigned int pe_get32 PARAMS ((bfd *, int));
static unsigned int pe_as32 PARAMS ((void *));
if (pe_dll_do_default_excludes)
{
- char * p;
+ const char * p;
int len;
if (pe_dll_extra_pe_debug)
}
/* Next, exclude symbols from certain startup objects. */
- afptr = autofilter_objlist;
- while (afptr->name)
+ if (abfd && (p = lbasename (abfd->filename)))
{
- if (abfd &&
- (p = strstr (abfd->filename, afptr->name)) &&
- (*(p + afptr->len - 1) == 0))
- return 0;
-
- afptr ++;
+ afptr = autofilter_objlist;
+ while (afptr->name)
+ {
+ if ( strcmp (p, afptr->name) == 0 )
+ return 0;
+ afptr++;
+ }
}
/* Don't try to blindly exclude all symbols
void
pe_walk_relocs_of_symbol (info, name, cb)
struct bfd_link_info *info;
- CONST char *name;
+ const char *name;
int (*cb) (arelent *, asection *);
{
bfd *b;
if (*cp == '\''
|| *cp == '"'
|| *cp == '\\'
- || isspace ((unsigned char) *cp)
+ || ISSPACE (*cp)
|| *cp == ','
|| *cp == ';')
needs_quotes = 1;
static void
quick_symbol (abfd, n1, n2, n3, sec, flags, addr)
bfd *abfd;
- char *n1;
- char *n2;
- char *n3;
+ const char *n1;
+ const char *n2;
+ const char *n3;
asection *sec;
int flags;
int addr;
static bfd *
make_singleton_name_thunk (import, parent)
- char *import;
+ const char *import;
bfd *parent;
{
/* Name thunks go to idata$4. */
/* We convert reloc to symbol, for later reference. */
static int counter;
static char *fixup_name = NULL;
- static unsigned int buffer_len = 0;
+ static size_t buffer_len = 0;
struct symbol_cache_entry *sym = *rel->sym_ptr_ptr;
static bfd *
make_import_fixup_entry (name, fixup_name, dll_symname,parent)
- char *name;
- char *fixup_name;
- char *dll_symname;
+ const char *name;
+ const char *fixup_name;
+ const char *dll_symname;
bfd *parent;
{
asection *id3;
char buf[300];
struct symbol_cache_entry *sym = *rel->sym_ptr_ptr;
struct bfd_link_hash_entry *name_thunk_sym;
- CONST char *name = sym->name;
+ const char *name = sym->name;
char *fixup_name = make_import_fixup_mark (rel);
sprintf (buf, U ("_nm_thnk_%s"), name);
}
{
- extern char * pe_data_import_dll; /* Defined in emultempl/pe.em. */
-
- bfd *b = make_import_fixup_entry (name, fixup_name, pe_data_import_dll,
+ extern char * pe_data_import_dll;
+ char * dll_symname = pe_data_import_dll ? pe_data_import_dll : "unknown";
+
+ bfd *b = make_import_fixup_entry (name, fixup_name, dll_symname,
output_bfd);
add_bfd_to_link (b, b->filename, &link_info);
}
dll_filename = (def->name) ? def->name : dll_name;
dll_symname = xstrdup (dll_filename);
for (i = 0; dll_symname[i]; i++)
- if (!isalnum ((unsigned char) dll_symname[i]))
+ if (!ISALNUM (dll_symname[i]))
dll_symname[i] = '_';
unlink (impfilename);
static void
add_bfd_to_link (abfd, name, link_info)
bfd *abfd;
- CONST char *name;
+ const char *name;
struct bfd_link_info *link_info;
{
lang_input_statement_type *fake_file;
dll_filename = module->name;
dll_symname = xstrdup (module->name);
for (i = 0; dll_symname[i]; i++)
- if (!isalnum (dll_symname[i]))
+ if (!ISALNUM (dll_symname[i]))
dll_symname[i] = '_';
do_this_dll = 0;
{
unsigned char b[2];
- bfd_seek (abfd, where, SEEK_SET);
- bfd_read (b, 1, 2, abfd);
+ bfd_seek (abfd, (file_ptr) where, SEEK_SET);
+ bfd_bread (b, (bfd_size_type) 2, abfd);
return b[0] + (b[1] << 8);
}
{
unsigned char b[4];
- bfd_seek (abfd, where, SEEK_SET);
- bfd_read (b, 1, 4, abfd);
+ bfd_seek (abfd, (file_ptr) where, SEEK_SET);
+ bfd_bread (b, (bfd_size_type) 4, abfd);
return b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24);
}
unsigned long vsize = pe_get32 (dll, secptr1 + 16);
unsigned long fptr = pe_get32 (dll, secptr1 + 20);
- bfd_seek (dll, secptr1, SEEK_SET);
- bfd_read (sname, 1, 8, dll);
+ bfd_seek (dll, (file_ptr) secptr1, SEEK_SET);
+ bfd_bread (sname, (bfd_size_type) 8, dll);
if (vaddr <= export_rva && vaddr + vsize > export_rva)
{
}
expdata = (unsigned char *) xmalloc (export_size);
- bfd_seek (dll, expptr, SEEK_SET);
- bfd_read (expdata, 1, export_size, dll);
+ bfd_seek (dll, (file_ptr) expptr, SEEK_SET);
+ bfd_bread (expdata, (bfd_size_type) export_size, dll);
erva = expdata - export_rva;
if (pe_def_file == 0)
/* Do the assignments again. */
lang_do_assignments (stat_ptr->head,
abs_output_section,
- (fill_type) 0, (bfd_vma) 0);
+ (fill_type *) 0, (bfd_vma) 0);
}
fill_edata (abfd, info);
/* Do the assignments again. */
lang_do_assignments (stat_ptr->head,
abs_output_section,
- (fill_type) 0, (bfd_vma) 0);
+ (fill_type *) 0, (bfd_vma) 0);
}
reloc_s->contents = reloc_d;
}