/* dlltool.c -- tool to generate stuff for PE style DLLs
- Copyright 1995, 1996, 1997, 1998, 1999, 2000
+ Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This file is part of GNU Binutils.
#include "demangle.h"
#include "dyn-string.h"
#include "dlltool.h"
+#include "safe-ctype.h"
-#include <ctype.h>
#include <time.h>
#include <sys/stat.h>
/* True if we should exclude the symbols in DEFAULT_EXCLUDES when
exporting all symbols. */
-static boolean do_default_excludes;
+static boolean do_default_excludes=true;
/* Default symbols to exclude when exporting all the symbols. */
static const char *default_excludes = "DllMain@12,DllEntryPoint@0,impure_ptr";
#define NSECS 7
-#define INIT_SEC_DATA(id, name, flags, align) { id, name, flags, align, NULL, NULL, NULL, 0, NULL }
+#define TEXT_SEC_FLAGS \
+ (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS)
+#define DATA_SEC_FLAGS (SEC_ALLOC | SEC_LOAD | SEC_DATA)
+#define BSS_SEC_FLAGS SEC_ALLOC
+
+#define INIT_SEC_DATA(id, name, flags, align) \
+ { id, name, flags, align, NULL, NULL, NULL, 0, NULL }
static sinfo secdata[NSECS] =
{
- INIT_SEC_DATA (TEXT, ".text", SEC_CODE | SEC_HAS_CONTENTS, 2),
- INIT_SEC_DATA (DATA, ".data", SEC_DATA, 2),
- INIT_SEC_DATA (BSS, ".bss", 0, 2),
- INIT_SEC_DATA (IDATA7, ".idata$7", SEC_HAS_CONTENTS, 2),
- INIT_SEC_DATA (IDATA5, ".idata$5", SEC_HAS_CONTENTS, 2),
- INIT_SEC_DATA (IDATA4, ".idata$4", SEC_HAS_CONTENTS, 2),
- INIT_SEC_DATA (IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1)
+ INIT_SEC_DATA (TEXT, ".text", TEXT_SEC_FLAGS, 2),
+ INIT_SEC_DATA (DATA, ".data", DATA_SEC_FLAGS, 2),
+ INIT_SEC_DATA (BSS, ".bss", BSS_SEC_FLAGS, 2),
+ INIT_SEC_DATA (IDATA7, ".idata$7", SEC_HAS_CONTENTS, 2),
+ INIT_SEC_DATA (IDATA5, ".idata$5", SEC_HAS_CONTENTS, 2),
+ INIT_SEC_DATA (IDATA4, ".idata$4", SEC_HAS_CONTENTS, 2),
+ INIT_SEC_DATA (IDATA6, ".idata$6", SEC_HAS_CONTENTS, 1)
};
#else
{
bfd * abfd;
asymbol * exp_label;
- asymbol * iname;
+ asymbol * iname = 0;
asymbol * iname2;
asymbol * iname_lab;
asymbol ** iname_lab_pp;
#define EXTRA 0
#endif
asymbol * ptrs[NSECS + 4 + EXTRA + 1];
+ flagword applicable;
char * outname = xmalloc (10);
int oidx = 0;
bfd_set_private_flags (abfd, F_INTERWORK);
#endif
+ applicable = bfd_applicable_section_flags (abfd);
+
/* First make symbols for the sections */
for (i = 0; i < NSECS; i++)
{
si->sec = bfd_make_section_old_way (abfd, si->name);
bfd_set_section_flags (abfd,
si->sec,
- si->flags);
+ si->flags & applicable);
bfd_set_section_alignment(abfd, si->sec, si->align);
si->sec->output_section = si->sec;
int status;
{
/* xgetext:c-format */
- fprintf (file, _("Usage %s <options> <object-files>\n"), program_name);
+ fprintf (file, _("Usage %s <option(s)> <object-file(s)>\n"), program_name);
/* xgetext:c-format */
fprintf (file, _(" -m --machine <machine> Create as DLL for <machine>. [default: %s]\n"), mname);
fprintf (file, _(" possible <machine>: arm[_interwork], i386, mcore[-elf]{-le|-be}, ppc, thumb\n"));
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
setlocale (LC_MESSAGES, "");
+#endif
+#if defined (HAVE_SETLOCALE)
+ setlocale (LC_CTYPE, "");
#endif
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
while ((c = getopt_long (ac, av,
#ifdef DLLTOOL_MCORE_ELF
- "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVhM:L:F:",
+ "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVHhM:L:F:",
#else
- "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVh",
+ "m:e:l:aD:d:z:b:xcCuUkAS:f:nvVHh",
#endif
long_options, 0))
!= EOF)
case 'e':
exp_name = optarg;
break;
+ case 'H':
case 'h':
usage (stdout, 0);
break;
imp_name_lab = xstrdup (imp_name);
for (p = imp_name_lab; *p; p++)
{
- if (!isalpha ((unsigned char) *p) && !isdigit ((unsigned char) *p))
+ if (!ISALNUM (*p))
*p = '_';
}
head_label = make_label("_head_", imp_name_lab);