X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=binutils%2Fdlltool.c;h=d22ff54e098a19551ebab7ba8e2a02cf18002c00;hb=refs%2Fheads%2Fconcurrent-displaced-stepping-2020-04-01;hp=f97c6b4e093704eec57e0f6dec64095d7a5bce9c;hpb=6f2750feaf2827ef8a1a0a5b2f90c1e9a6cabbd1;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/dlltool.c b/binutils/dlltool.c index f97c6b4e09..d22ff54e09 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -1,5 +1,5 @@ /* dlltool.c -- tool to generate stuff for PE style DLLs - Copyright (C) 1995-2016 Free Software Foundation, Inc. + Copyright (C) 1995-2020 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -240,6 +240,7 @@ #include "bucomm.h" #include "dlltool.h" #include "safe-ctype.h" +#include "coff-bfd.h" #include #include @@ -436,10 +437,6 @@ static FILE *base_file; static const char *mname = "arm"; #endif -#ifdef DLLTOOL_DEFAULT_ARM_EPOC -static const char *mname = "arm-epoc"; -#endif - #ifdef DLLTOOL_DEFAULT_ARM_WINCE static const char *mname = "arm-wince"; #endif @@ -733,17 +730,7 @@ mtable[] = } , { -#define MARM_EPOC 9 - "arm-epoc", ".byte", ".short", ".long", ".asciz", "@", - "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", - ".global", ".space", ".align\t2",".align\t4", "", - "epoc-pe-arm-little", bfd_arch_arm, - arm_jtab, sizeof (arm_jtab), 8, - 0, 0, 0, 0, 0, 0 - } - , - { -#define MARM_WINCE 10 +#define MARM_WINCE 9 "arm-wince", ".byte", ".short", ".long", ".asciz", "@", "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", ".global", ".space", ".align\t2",".align\t4", "-mapcs-32", @@ -753,7 +740,7 @@ mtable[] = } , { -#define MX86 11 +#define MX86 10 "i386:x86-64", ".byte", ".short", ".long", ".asciz", "#", "jmp *", ".global", ".space", ".align\t2",".align\t4", "", "pe-x86-64",bfd_arch_i386, @@ -780,10 +767,9 @@ typedef struct export int ordinal; int constant; int noname; /* Don't put name in image file. */ - int private; /* Don't put reference in import lib. */ + int private; /* Don't put reference in import lib. */ int data; - int hint; - int forward; /* Number of forward label, 0 means no forward. */ + int forward; /* Number of forward label, 0 means no forward. */ struct export *next; } export_type; @@ -909,7 +895,6 @@ rvaafter (int mach) case MMCORE_LE: case MMCORE_ELF: case MMCORE_ELF_LE: - case MARM_EPOC: case MARM_WINCE: break; default: @@ -935,7 +920,6 @@ rvabefore (int mach) case MMCORE_LE: case MMCORE_ELF: case MMCORE_ELF_LE: - case MARM_EPOC: case MARM_WINCE: return ".rva\t"; default: @@ -959,7 +943,6 @@ asm_prefix (int mach, const char *name) case MMCORE_LE: case MMCORE_ELF: case MMCORE_ELF_LE: - case MARM_EPOC: case MARM_WINCE: break; case M386: @@ -1253,7 +1236,7 @@ def_import (const char *app_name, const char *module, const char *dllext, const char *entry, int ord_val, const char *its_name) { const char *application_name; - char *buf; + char *buf = NULL; if (entry != NULL) application_name = entry; @@ -1266,13 +1249,11 @@ def_import (const char *app_name, const char *module, const char *dllext, } if (dllext != NULL) - { - buf = (char *) alloca (strlen (module) + strlen (dllext) + 2); - sprintf (buf, "%s.%s", module, dllext); - module = buf; - } + module = buf = concat (module, ".", dllext, NULL); append_import (application_name, module, ord_val, its_name); + + free (buf); } void @@ -1334,7 +1315,7 @@ run (const char *what, char *args) if (*s == ' ') i++; i++; - argv = alloca (sizeof (char *) * (i + 3)); + argv = xmalloc (sizeof (char *) * (i + 3)); i = 0; argv[i++] = what; s = args; @@ -1353,6 +1334,7 @@ run (const char *what, char *args) pid = pexecute (argv[0], (char * const *) argv, program_name, temp_base, &errmsg_fmt, &errmsg_arg, PEXECUTE_ONE | PEXECUTE_SEARCH); + free (argv); if (pid == -1) { @@ -1402,7 +1384,7 @@ scan_drectve_symbols (bfd *abfd) if (s == NULL) return; - size = bfd_get_section_size (s); + size = bfd_section_size (s); buf = xmalloc (size); bfd_get_section_contents (abfd, s, buf, 0, size); @@ -1986,12 +1968,13 @@ assemble_file (const char * source, const char * dest) { char * cmd; - cmd = (char *) alloca (strlen (ASM_SWITCHES) + strlen (as_flags) - + strlen (source) + strlen (dest) + 50); + cmd = xmalloc (strlen (ASM_SWITCHES) + strlen (as_flags) + + strlen (source) + strlen (dest) + 50); sprintf (cmd, "%s %s -o %s %s", ASM_SWITCHES, as_flags, dest, source); run (as_name, cmd); + free (cmd); } static const char * temp_file_to_remove[5]; @@ -2499,11 +2482,9 @@ make_one_lib_file (export_type *exp, int i, int delay) if (si->id != i) abort (); si->sec = bfd_make_section_old_way (abfd, si->name); - bfd_set_section_flags (abfd, - si->sec, - si->flags & applicable); + bfd_set_section_flags (si->sec, si->flags & applicable); - bfd_set_section_alignment(abfd, si->sec, si->align); + bfd_set_section_alignment (si->sec, si->align); si->sec->output_section = si->sec; si->sym = bfd_make_empty_symbol(abfd); si->sym->name = si->sec->name; @@ -2707,7 +2688,8 @@ make_one_lib_file (export_type *exp, int i, int delay) sec->orelocation = rpp; break; } - /* else fall through */ + /* Fall through. */ + case IDATA4: /* An idata$4 or idata$5 is one word long, and has an rva to idata$6. */ @@ -2774,10 +2756,8 @@ make_one_lib_file (export_type *exp, int i, int delay) case IDATA6: if (!exp->noname) { - /* This used to add 1 to exp->hint. I don't know - why it did that, and it does not match what I see - in programs compiled with the MS tools. */ - int idx = exp->hint; + int idx = exp->ordinal; + if (exp->its_name) si->size = strlen (exp->its_name) + 3; else @@ -2840,7 +2820,7 @@ make_one_lib_file (export_type *exp, int i, int delay) arelent *imglue, *ba_rel, *ea_rel, *pea_rel; /* Alignment must be set to 2**2 or you get extra stuff. */ - bfd_set_section_alignment(abfd, sec, 2); + bfd_set_section_alignment (sec, 2); si->size = 4 * 5; si->data = xmalloc (si->size); @@ -2926,8 +2906,8 @@ make_one_lib_file (export_type *exp, int i, int delay) { sinfo *si = secdata + i; - bfd_set_section_size (abfd, si->sec, si->size); - bfd_set_section_vma (abfd, si->sec, vma); + bfd_set_section_size (si->sec, si->size); + bfd_set_section_vma (si->sec, vma); } } /* Write them out. */ @@ -3261,7 +3241,6 @@ gen_lib_file (int delay) alias_exp.noname = exp->noname; alias_exp.private = exp->private; alias_exp.data = exp->data; - alias_exp.hint = exp->hint; alias_exp.forward = exp->forward; alias_exp.next = exp->next; n = make_one_lib_file (&alias_exp, i + PREFIX_ALIAS_BASE, delay); @@ -3295,7 +3274,7 @@ gen_lib_file (int delay) { char *name; - name = (char *) alloca (strlen (TMP_STUB) + 10); + name = xmalloc (strlen (TMP_STUB) + 10); for (i = 0; (exp = d_exports_lexically[i]); i++) { /* Don't delete non-existent stubs for PRIVATE entries. */ @@ -3313,6 +3292,7 @@ gen_lib_file (int delay) non_fatal (_("cannot delete %s: %s"), name, strerror (errno)); } } + free (name); } inform (_("Created lib file")); @@ -3407,15 +3387,8 @@ dll_name_list_free_contents (dll_name_list_node_type * entry) if (entry) { if (entry->next) - { - dll_name_list_free_contents (entry->next); - entry->next = NULL; - } - if (entry->dllname) - { - free (entry->dllname); - entry->dllname = NULL; - } + dll_name_list_free_contents (entry->next); + free (entry->dllname); free (entry); } } @@ -3522,7 +3495,8 @@ identify_dll_for_implib (void) search_data.symname = "__NULL_IMPORT_DESCRIPTOR"; search_data.found = FALSE; - bfd_init (); + if (bfd_init () != BFD_INIT_MAGIC) + fatal (_("fatal error: libbfd ABI mismatch")); abfd = bfd_openr (identify_imp_name, 0); if (abfd == NULL) @@ -3708,7 +3682,7 @@ identify_search_section (bfd * abfd, asection * section, void * obj) if (ms_style && ((section->flags & SEC_DATA) == 0)) return; - if ((datasize = bfd_section_size (abfd, section)) == 0) + if ((datasize = bfd_section_size (section)) == 0) return; data = (bfd_byte *) xmalloc (datasize + 1); @@ -3924,10 +3898,8 @@ mangle_defs (void) { /* First work out the minimum ordinal chosen. */ export_type *exp; - - int i; - int hint = 0; export_type **d_export_vec = xmalloc (sizeof (export_type *) * d_nfuncs); + int i; inform (_("Processing definitions")); @@ -3956,11 +3928,6 @@ mangle_defs (void) qsort (d_exports_lexically, i, sizeof (export_type *), nfunc); - /* Fill exp entries with their hint values. */ - for (i = 0; i < d_nfuncs; i++) - if (!d_exports_lexically[i]->noname || show_allnames) - d_exports_lexically[i]->hint = hint++; - inform (_("Processed definitions")); }