diff options
author | Alan Modra <amodra@gmail.com> | 2024-08-28 18:48:41 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2024-08-28 22:19:38 +0930 |
commit | 57a3845126b3cbba672efc31a15941b3e2c9d8bd (patch) | |
tree | a9c696094940bb80205cd0ecf9990237d0e74c7f /binutils | |
parent | 0eb85fc2422bf668d95fd7bd96ea0d39043d3d3e (diff) | |
download | binutils-57a3845126b3cbba672efc31a15941b3e2c9d8bd.zip binutils-57a3845126b3cbba672efc31a15941b3e2c9d8bd.tar.gz binutils-57a3845126b3cbba672efc31a15941b3e2c9d8bd.tar.bz2 |
dlltool.c formatting
Mostly whitespace fixes, some removal of excess parens.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/dlltool.c | 449 |
1 files changed, 226 insertions, 223 deletions
diff --git a/binutils/dlltool.c b/binutils/dlltool.c index c7c4e74..d75a99d 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -334,16 +334,16 @@ static void mcore_elf_gen_out_file (void); typedef struct ifunct { - char * name; /* Name of function being imported. */ - char * its_name; /* Optional import table symbol name. */ - int ord; /* Two-byte ordinal value associated with function. */ + char * name; /* Name of function being imported. */ + char * its_name; /* Optional import table symbol name. */ + int ord; /* Two-byte ordinal value associated with function. */ struct ifunct *next; } ifunctype; typedef struct iheadt { - char * dllname; /* Name of dll file imported from. */ - long nfuncs; /* Number of functions in list. */ + char * dllname; /* Name of dll file imported from. */ + long nfuncs; /* Number of functions in list. */ struct ifunct *funchead; /* First function in list. */ struct ifunct *functail; /* Last function in list. */ struct iheadt *next; /* Next dll file in list. */ @@ -371,7 +371,7 @@ static bool deterministic = DEFAULT_AR_DETERMINISTIC; (head->dllname is NULL). */ typedef struct dll_name_list_node_t { - char * dllname; + char * dllname; struct dll_name_list_node_t * next; } dll_name_list_node_type; @@ -515,69 +515,69 @@ static const unsigned char i386_jtab[] = static const unsigned char i386_dljtab[] = { - 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, /* jmp __imp__function */ - 0xB8, 0x00, 0x00, 0x00, 0x00, /* mov eax, offset __imp__function */ - 0xE9, 0x00, 0x00, 0x00, 0x00 /* jmp __tailMerge__dllname */ + 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, /* jmp __imp__function */ + 0xB8, 0x00, 0x00, 0x00, 0x00, /* mov eax, offset __imp__function */ + 0xE9, 0x00, 0x00, 0x00, 0x00 /* jmp __tailMerge__dllname */ }; static const unsigned char i386_x64_dljtab[] = { - 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, /* jmp __imp__function */ - 0x48, 0x8d, 0x05, /* leaq rax, (__imp__function) */ - 0x00, 0x00, 0x00, 0x00, - 0xE9, 0x00, 0x00, 0x00, 0x00 /* jmp __tailMerge__dllname */ + 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, /* jmp __imp__function */ + 0x48, 0x8d, 0x05, /* leaq rax, (__imp__function) */ + 0x00, 0x00, 0x00, 0x00, + 0xE9, 0x00, 0x00, 0x00, 0x00 /* jmp __tailMerge__dllname */ }; static const unsigned char arm_jtab[] = { 0x00, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */ 0x00, 0xf0, 0x9c, 0xe5, /* ldr pc, [ip] */ - 0, 0, 0, 0 + 0, 0, 0, 0 }; static const unsigned char arm_interwork_jtab[] = { - 0x04, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */ - 0x00, 0xc0, 0x9c, 0xe5, /* ldr ip, [ip] */ - 0x1c, 0xff, 0x2f, 0xe1, /* bx ip */ - 0, 0, 0, 0 + 0x04, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */ + 0x00, 0xc0, 0x9c, 0xe5, /* ldr ip, [ip] */ + 0x1c, 0xff, 0x2f, 0xe1, /* bx ip */ + 0, 0, 0, 0 }; static const unsigned char thumb_jtab[] = { - 0x40, 0xb4, /* push {r6} */ - 0x02, 0x4e, /* ldr r6, [pc, #8] */ - 0x36, 0x68, /* ldr r6, [r6] */ - 0xb4, 0x46, /* mov ip, r6 */ - 0x40, 0xbc, /* pop {r6} */ - 0x60, 0x47, /* bx ip */ - 0, 0, 0, 0 + 0x40, 0xb4, /* push {r6} */ + 0x02, 0x4e, /* ldr r6, [pc, #8] */ + 0x36, 0x68, /* ldr r6, [r6] */ + 0xb4, 0x46, /* mov ip, r6 */ + 0x40, 0xbc, /* pop {r6} */ + 0x60, 0x47, /* bx ip */ + 0, 0, 0, 0 }; static const unsigned char mcore_be_jtab[] = { - 0x71, 0x02, /* lrw r1,2 */ - 0x81, 0x01, /* ld.w r1,(r1,0) */ - 0x00, 0xC1, /* jmp r1 */ - 0x12, 0x00, /* nop */ - 0x00, 0x00, 0x00, 0x00 /* <address> */ + 0x71, 0x02, /* lrw r1,2 */ + 0x81, 0x01, /* ld.w r1,(r1,0) */ + 0x00, 0xC1, /* jmp r1 */ + 0x12, 0x00, /* nop */ + 0x00, 0x00, 0x00, 0x00 /* <address> */ }; static const unsigned char mcore_le_jtab[] = { - 0x02, 0x71, /* lrw r1,2 */ - 0x01, 0x81, /* ld.w r1,(r1,0) */ - 0xC1, 0x00, /* jmp r1 */ - 0x00, 0x12, /* nop */ - 0x00, 0x00, 0x00, 0x00 /* <address> */ + 0x02, 0x71, /* lrw r1,2 */ + 0x01, 0x81, /* ld.w r1,(r1,0) */ + 0xC1, 0x00, /* jmp r1 */ + 0x00, 0x12, /* nop */ + 0x00, 0x00, 0x00, 0x00 /* <address> */ }; static const unsigned char aarch64_jtab[] = { - 0x10, 0x00, 0x00, 0x90, /* adrp x16, 0 */ + 0x10, 0x00, 0x00, 0x90, /* adrp x16, 0 */ 0x10, 0x02, 0x00, 0x91, /* add x16, x16, #0x0 */ - 0x10, 0x02, 0x40, 0xf9, /* ldr x16, [x16] */ - 0x00, 0x02, 0x1f, 0xd6 /* br x16 */ + 0x10, 0x02, 0x40, 0xf9, /* ldr x16, [x16] */ + 0x00, 0x02, 0x1f, 0xd6 /* br x16 */ }; static const char i386_trampoline[] = @@ -669,7 +669,7 @@ mtable[] = #define MARM 0 "arm", ".byte", ".short", ".long", ".asciz", "@", "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", - ".global", ".space", ".align\t2",".align\t4", "-mapcs-32", + ".global", ".space", ".align\t2", ".align\t4", "-mapcs-32", "pe-arm-little", bfd_arch_arm, arm_jtab, sizeof (arm_jtab), 8, 0, 0, 0, 0, 0, false, 0 @@ -678,7 +678,7 @@ mtable[] = { #define M386 1 "i386", ".byte", ".short", ".long", ".asciz", "#", - "jmp *", ".global", ".space", ".align\t2",".align\t4", "", + "jmp *", ".global", ".space", ".align\t2", ".align\t4", "", "pe-i386",bfd_arch_i386, i386_jtab, sizeof (i386_jtab), 2, i386_dljtab, sizeof (i386_dljtab), 2, 7, 12, false, i386_trampoline @@ -688,7 +688,7 @@ mtable[] = #define MTHUMB 2 "thumb", ".byte", ".short", ".long", ".asciz", "@", "push\t{r6}\n\tldr\tr6, [pc, #8]\n\tldr\tr6, [r6]\n\tmov\tip, r6\n\tpop\t{r6}\n\tbx\tip", - ".global", ".space", ".align\t2",".align\t4", "-mthumb-interwork", + ".global", ".space", ".align\t2", ".align\t4", "-mthumb-interwork", "pe-arm-little", bfd_arch_arm, thumb_jtab, sizeof (thumb_jtab), 12, 0, 0, 0, 0, 0, false, 0 @@ -698,7 +698,7 @@ mtable[] = { "arm_interwork", ".byte", ".short", ".long", ".asciz", "@", "ldr\tip,[pc]\n\tldr\tip,[ip]\n\tbx\tip\n\t.long", - ".global", ".space", ".align\t2",".align\t4", "-mthumb-interwork", + ".global", ".space", ".align\t2", ".align\t4", "-mthumb-interwork", "pe-arm-little", bfd_arch_arm, arm_interwork_jtab, sizeof (arm_interwork_jtab), 12, 0, 0, 0, 0, 0, false, 0 @@ -708,7 +708,7 @@ mtable[] = #define MMCORE_BE 4 "mcore-be", ".byte", ".short", ".long", ".asciz", "//", "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", - ".global", ".space", ".align\t2",".align\t4", "", + ".global", ".space", ".align\t2", ".align\t4", "", "pe-mcore-big", bfd_arch_mcore, mcore_be_jtab, sizeof (mcore_be_jtab), 8, 0, 0, 0, 0, 0, false, 0 @@ -718,7 +718,7 @@ mtable[] = #define MMCORE_LE 5 "mcore-le", ".byte", ".short", ".long", ".asciz", "//", "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", - ".global", ".space", ".align\t2",".align\t4", "-EL", + ".global", ".space", ".align\t2", ".align\t4", "-EL", "pe-mcore-little", bfd_arch_mcore, mcore_le_jtab, sizeof (mcore_le_jtab), 8, 0, 0, 0, 0, 0, false, 0 @@ -728,7 +728,7 @@ mtable[] = #define MMCORE_ELF 6 "mcore-elf-be", ".byte", ".short", ".long", ".asciz", "//", "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", - ".global", ".space", ".align\t2",".align\t4", "", + ".global", ".space", ".align\t2", ".align\t4", "", "elf32-mcore-big", bfd_arch_mcore, mcore_be_jtab, sizeof (mcore_be_jtab), 8, 0, 0, 0, 0, 0, false, 0 @@ -738,7 +738,7 @@ mtable[] = #define MMCORE_ELF_LE 7 "mcore-elf-le", ".byte", ".short", ".long", ".asciz", "//", "lrw r1,[1f]\n\tld.w r1,(r1,0)\n\tjmp r1\n\tnop\n1:.long", - ".global", ".space", ".align\t2",".align\t4", "-EL", + ".global", ".space", ".align\t2", ".align\t4", "-EL", "elf32-mcore-little", bfd_arch_mcore, mcore_le_jtab, sizeof (mcore_le_jtab), 8, 0, 0, 0, 0, 0, false, 0 @@ -748,7 +748,7 @@ mtable[] = #define MARM_WINCE 8 "arm-wince", ".byte", ".short", ".long", ".asciz", "@", "ldr\tip,[pc]\n\tldr\tpc,[ip]\n\t.long", - ".global", ".space", ".align\t2",".align\t4", "-mapcs-32", + ".global", ".space", ".align\t2", ".align\t4", "-mapcs-32", "pe-arm-wince-little", bfd_arch_arm, arm_jtab, sizeof (arm_jtab), 8, 0, 0, 0, 0, 0, false, 0 @@ -757,7 +757,7 @@ mtable[] = { #define MX86 9 "i386:x86-64", ".byte", ".short", ".long", ".asciz", "#", - "jmp *", ".global", ".space", ".align\t2",".align\t4", "", + "jmp *", ".global", ".space", ".align\t2", ".align\t4", "", "pe-x86-64",bfd_arch_i386, i386_jtab, sizeof (i386_jtab), 2, i386_x64_dljtab, sizeof (i386_x64_dljtab), 2, 9, 14, true, i386_x64_trampoline @@ -925,9 +925,9 @@ asm_prefix (int mach, const char *name) case MX86: /* Symbol names starting with ? do not have a leading underscore. */ if ((name && *name == '?') || leading_underscore == 0) - break; + break; else - return "_"; + return "_"; default: /* xgettext:c-format */ fatal (_("Internal error: Unknown machine type: %d"), mach); @@ -1028,8 +1028,8 @@ def_exports (const char *name, const char *internal_name, int ordinal, d_exports = p; d_nfuncs++; - if ((internal_name != NULL) - && (strchr (internal_name, '.') != NULL)) + if (internal_name != NULL + && strchr (internal_name, '.') != NULL) p->forward = ++d_nforwards; else p->forward = 0; /* no forward */ @@ -1041,7 +1041,7 @@ set_dll_name_from_def (const char *name, char is_dll) const char *image_basename = lbasename (name); if (image_basename != name) non_fatal (_("%s: Path components stripped from image name, '%s'."), - def_file, name); + def_file, name); /* Append the default suffix, if none specified. */ if (strchr (image_basename, '.') == 0) { @@ -1155,7 +1155,7 @@ append_import (const char *symbol_name, const char *dllname, int func_ordinal, q->functail = q->functail->next; q->functail->ord = func_ordinal; q->functail->name = xstrdup (symbol_name); - q->functail->its_name = (its_name ? xstrdup (its_name) : NULL); + q->functail->its_name = its_name ? xstrdup (its_name) : NULL; q->functail->next = NULL; q->nfuncs++; return; @@ -1169,7 +1169,7 @@ append_import (const char *symbol_name, const char *dllname, int func_ordinal, q->functail = q->funchead; q->next = NULL; q->functail->name = xstrdup (symbol_name); - q->functail->its_name = (its_name ? xstrdup (its_name) : NULL); + q->functail->its_name = its_name ? xstrdup (its_name) : NULL; q->functail->ord = func_ordinal; q->functail->next = NULL; @@ -1260,7 +1260,6 @@ def_section (const char *name, int attr) void def_code (int attr) { - def_section ("CODE", attr); } @@ -1467,13 +1466,14 @@ scan_filtered_symbols (bfd *abfd, void *minisyms, long symcount, ! (sym->flags & BSF_FUNCTION), 0, NULL); if (add_stdcall_alias && strchr (symbol_name, '@')) - { + { int lead_at = (*symbol_name == '@'); char *exported_name = xstrdup (symbol_name + lead_at); char *atsym = strchr (exported_name, '@'); *atsym = '\0'; /* Note: stdcall alias symbols can never be data. */ - def_exports (exported_name, xstrdup (symbol_name), -1, 0, 0, 0, 0, NULL); + def_exports (exported_name, xstrdup (symbol_name), + -1, 0, 0, 0, 0, NULL); } } } @@ -1500,7 +1500,7 @@ add_excludes (const char *new_excludes) if (*exclude_string == '@') sprintf (new_exclude->string, "%s", exclude_string); else - sprintf (new_exclude->string, "%s%s", (!leading_underscore ? "" : "_"), + sprintf (new_exclude->string, "%s%s", !leading_underscore ? "" : "_", exclude_string); new_exclude->next = excludes; excludes = new_exclude; @@ -1665,7 +1665,8 @@ scan_obj_file (const char *filename) #ifdef DLLTOOL_MCORE_ELF if (mcore_elf_out_file) - inform (_("Cannot produce mcore-elf dll from archive file: %s"), filename); + inform (_("Cannot produce mcore-elf dll from archive file: %s"), + filename); #endif } else if (bfd_check_format (f, bfd_object)) @@ -1682,7 +1683,6 @@ scan_obj_file (const char *filename) } - static void dump_def_info (FILE *f) { @@ -1740,7 +1740,7 @@ flush_page (FILE *f, bfd_vma *need, bfd_vma page_addr, int on_page) bfd_vma needed = need[i]; if (needed) - { + { if (!create_for_pep) { /* Relocation via HIGHLOW. */ @@ -1782,7 +1782,7 @@ gen_def_file (void) if (res) { - fprintf (output_def,";\t%s\n", res); + fprintf (output_def, ";\t%s\n", res); free (res); } @@ -1870,7 +1870,7 @@ generate_idata_ofile (FILE *filvar) { fprintf (filvar, "listone%d:\n", headindex); for (funcindex = 0; funcindex < headptr->nfuncs; funcindex++) - { + { if (create_for_pep) fprintf (filvar, "\t%sfuncptr%d_%d%s\n%s\t0\n", ASM_RVA_BEFORE, headindex, funcindex, ASM_RVA_AFTER, @@ -1878,7 +1878,7 @@ generate_idata_ofile (FILE *filvar) else fprintf (filvar, "\t%sfuncptr%d_%d%s\n", ASM_RVA_BEFORE, headindex, funcindex, ASM_RVA_AFTER); - } + } if (create_for_pep) fprintf (filvar, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); else @@ -1892,7 +1892,7 @@ generate_idata_ofile (FILE *filvar) { fprintf (filvar, "listtwo%d:\n", headindex); for (funcindex = 0; funcindex < headptr->nfuncs; funcindex++) - { + { if (create_for_pep) fprintf (filvar, "\t%sfuncptr%d_%d%s\n%s\t0\n", ASM_RVA_BEFORE, headindex, funcindex, ASM_RVA_AFTER, @@ -1900,7 +1900,7 @@ generate_idata_ofile (FILE *filvar) else fprintf (filvar, "\t%sfuncptr%d_%d%s\n", ASM_RVA_BEFORE, headindex, funcindex, ASM_RVA_AFTER); - } + } if (create_for_pep) fprintf (filvar, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); else @@ -1916,12 +1916,11 @@ generate_idata_ofile (FILE *filvar) for (funcptr = headptr->funchead; funcptr != NULL; funcptr = funcptr->next) { - fprintf (filvar,"funcptr%d_%d:\n", headindex, funcindex); - fprintf (filvar,"\t%s\t%d\n", ASM_SHORT, - ((funcptr->ord) & 0xFFFF)); - fprintf (filvar,"\t%s\t\"%s\"\n", ASM_TEXT, - (funcptr->its_name ? funcptr->its_name : funcptr->name)); - fprintf (filvar,"\t%s\t0\n", ASM_BYTE); + fprintf (filvar, "funcptr%d_%d:\n", headindex, funcindex); + fprintf (filvar, "\t%s\t%d\n", ASM_SHORT, funcptr->ord & 0xFFFF); + fprintf (filvar, "\t%s\t\"%s\"\n", ASM_TEXT, + funcptr->its_name ? funcptr->its_name : funcptr->name); + fprintf (filvar, "\t%s\t0\n", ASM_BYTE); funcindex++; } headindex++; @@ -1931,9 +1930,9 @@ generate_idata_ofile (FILE *filvar) headindex = 0; for (headptr = import_list; headptr != NULL; headptr = headptr->next) { - fprintf (filvar,"dllname%d:\n", headindex); - fprintf (filvar,"\t%s\t\"%s\"\n", ASM_TEXT, headptr->dllname); - fprintf (filvar,"\t%s\t0\n", ASM_BYTE); + fprintf (filvar, "dllname%d:\n", headindex); + fprintf (filvar, "\t%s\t\"%s\"\n", ASM_TEXT, headptr->dllname); + fprintf (filvar, "\t%s\t0\n", ASM_BYTE); headindex++; } } @@ -2008,28 +2007,33 @@ gen_exp_file (void) fprintf (f, "\t%s 0x%lx %s Time and date\n", ASM_LONG, (unsigned long) time(0), ASM_C); fprintf (f, "\t%s 0 %s Major and Minor version\n", ASM_LONG, ASM_C); - fprintf (f, "\t%sname%s %s Ptr to name of dll\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); - fprintf (f, "\t%s %d %s Starting ordinal of exports\n", ASM_LONG, d_low_ord, ASM_C); + fprintf (f, "\t%sname%s %s Ptr to name of dll\n", + ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); + fprintf (f, "\t%s %d %s Starting ordinal of exports\n", + ASM_LONG, d_low_ord, ASM_C); - fprintf (f, "\t%s %d %s Number of functions\n", ASM_LONG, d_high_ord - d_low_ord + 1, ASM_C); - fprintf(f,"\t%s named funcs %d, low ord %d, high ord %d\n", - ASM_C, - d_named_nfuncs, d_low_ord, d_high_ord); + fprintf (f, "\t%s %d %s Number of functions\n", + ASM_LONG, d_high_ord - d_low_ord + 1, ASM_C); + fprintf (f, "\t%s named funcs %d, low ord %d, high ord %d\n", + ASM_C, d_named_nfuncs, d_low_ord, d_high_ord); fprintf (f, "\t%s %d %s Number of names\n", ASM_LONG, - show_allnames ? d_high_ord - d_low_ord + 1 : d_named_nfuncs, ASM_C); - fprintf (f, "\t%safuncs%s %s Address of functions\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); + show_allnames ? d_high_ord - d_low_ord + 1 : d_named_nfuncs, + ASM_C); + fprintf (f, "\t%safuncs%s %s Address of functions\n", + ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); fprintf (f, "\t%sanames%s %s Address of Name Pointer Table\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); - fprintf (f, "\t%sanords%s %s Address of ordinals\n", ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); + fprintf (f, "\t%sanords%s %s Address of ordinals\n", + ASM_RVA_BEFORE, ASM_RVA_AFTER, ASM_C); fprintf (f, "name: %s \"%s\"\n", ASM_TEXT, dll_name); - fprintf(f,"%s Export address Table\n", ASM_C); - fprintf(f,"\t%s\n", ASM_ALIGN_LONG); + fprintf (f, "%s Export address Table\n", ASM_C); + fprintf (f, "\t%s\n", ASM_ALIGN_LONG); fprintf (f, "afuncs:\n"); i = d_low_ord; @@ -2039,7 +2043,7 @@ gen_exp_file (void) { while (i < exp->ordinal) { - fprintf(f,"\t%s\t0\n", ASM_LONG); + fprintf (f, "\t%s\t0\n", ASM_LONG); i++; } } @@ -2060,7 +2064,7 @@ gen_exp_file (void) i++; } - fprintf (f,"%s Export Name Pointer Table\n", ASM_C); + fprintf (f, "%s Export Name Pointer Table\n", ASM_C); fprintf (f, "anames:\n"); for (i = 0; (exp = d_exports_lexically[i]); i++) @@ -2070,7 +2074,7 @@ gen_exp_file (void) ASM_RVA_BEFORE, exp->ordinal, ASM_RVA_AFTER); } - fprintf (f,"%s Export Ordinal Table\n", ASM_C); + fprintf (f, "%s Export Ordinal Table\n", ASM_C); fprintf (f, "anords:\n"); for (i = 0; (exp = d_exports_lexically[i]); i++) { @@ -2078,13 +2082,13 @@ gen_exp_file (void) fprintf (f, "\t%s %d\n", ASM_SHORT, exp->ordinal - d_low_ord); } - fprintf(f,"%s Export Name Table\n", ASM_C); + fprintf (f, "%s Export Name Table\n", ASM_C); for (i = 0; (exp = d_exports_lexically[i]); i++) { if (!exp->noname || show_allnames) fprintf (f, "n%d: %s \"%s\"\n", exp->ordinal, ASM_TEXT, - (exp->its_name ? exp->its_name : xlate (exp->name))); + exp->its_name ? exp->its_name : xlate (exp->name)); if (exp->forward != 0) fprintf (f, "f%d: %s \"%s\"\n", exp->forward, ASM_TEXT, exp->internal_name); @@ -2108,7 +2112,7 @@ gen_exp_file (void) int l; /* We don't output as ascii because there can - be quote characters in the string. */ + be quote characters in the string. */ l = 0; for (p = dl->text; *p; p++) { @@ -2141,15 +2145,16 @@ gen_exp_file (void) if (!exp->noname || show_allnames) { /* We use a single underscore for MS compatibility, and a - double underscore for backward compatibility with old - cygwin releases. */ + double underscore for backward compatibility with old + cygwin releases. */ if (create_compat_implib) fprintf (f, "\t%s\t__imp_%s\n", ASM_GLOBAL, exp->name); fprintf (f, "\t%s\t_imp_%s%s\n", ASM_GLOBAL, - (!leading_underscore ? "" : "_"), exp->name); + !leading_underscore ? "" : "_", exp->name); if (create_compat_implib) fprintf (f, "__imp_%s:\n", exp->name); - fprintf (f, "_imp_%s%s:\n", (!leading_underscore ? "" : "_"), exp->name); + fprintf (f, "_imp_%s%s:\n", + !leading_underscore ? "" : "_", exp->name); fprintf (f, "\t%s\t%s\n", ASM_LONG, exp->name); } } @@ -2176,7 +2181,6 @@ gen_exp_file (void) fatal (_("failed to read the number of entries from base file")); num_entries = numbytes / sizeof (bfd_vma); - fprintf (f, "\t.section\t.reloc\n"); if (num_entries) { @@ -2206,8 +2210,9 @@ gen_exp_file (void) need[on_page++] = addr; } flush_page (f, need, page_addr, on_page); - -/* fprintf (f, "\t%s\t0,0\t%s End\n", ASM_LONG, ASM_C);*/ +#if 0 + fprintf (f, "\t%s\t0,0\t%s End\n", ASM_LONG, ASM_C); +#endif } } @@ -2230,8 +2235,8 @@ gen_exp_file (void) static const char * xlate (const char *name) { - int lead_at = (*name == '@'); - int is_stdcall = (!lead_at && strchr (name, '@') != NULL); + int lead_at = *name == '@'; + int is_stdcall = !lead_at && strchr (name, '@') != NULL; if (!lead_at && (add_underscore || (add_stdcall_underscore && is_stdcall))) @@ -2270,7 +2275,7 @@ typedef struct } sinfo; #define INIT_SEC_DATA(id, name, flags, align) \ - { id, name, flags, align, NULL, NULL, NULL, 0, NULL } + { id, name, flags, align, NULL, NULL, NULL, 0, NULL } #define TEXT 0 #define DATA 1 @@ -2283,7 +2288,7 @@ typedef struct #define NSECS 7 #define TEXT_SEC_FLAGS \ - (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS) + (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 @@ -2507,17 +2512,17 @@ make_one_lib_file (export_type *exp, int i, int delay) rel->addend = 0; if (delay) - { - rel2 = xmalloc (sizeof (arelent)); - rpp[1] = rel2; - rel2->address = HOW_JTAB_ROFF2; - rel2->addend = 0; - rel3 = xmalloc (sizeof (arelent)); - rpp[2] = rel3; - rel3->address = HOW_JTAB_ROFF3; - rel3->addend = 0; - rpp[3] = 0; - } + { + rel2 = xmalloc (sizeof (arelent)); + rpp[1] = rel2; + rel2->address = HOW_JTAB_ROFF2; + rel2->addend = 0; + rel3 = xmalloc (sizeof (arelent)); + rpp[2] = rel3; + rel3->address = HOW_JTAB_ROFF3; + rel3->addend = 0; + rpp[3] = 0; + } if (machine == MX86) { @@ -2548,17 +2553,17 @@ make_one_lib_file (export_type *exp, int i, int delay) } if (delay) - { + { if (machine == MX86) - rel2->howto = bfd_reloc_type_lookup (abfd, - BFD_RELOC_32_PCREL); - else - rel2->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); - rel2->sym_ptr_ptr = rel->sym_ptr_ptr; - rel3->howto = bfd_reloc_type_lookup (abfd, + rel2->howto = bfd_reloc_type_lookup (abfd, + BFD_RELOC_32_PCREL); + else + rel2->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + rel2->sym_ptr_ptr = rel->sym_ptr_ptr; + rel3->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32_PCREL); - rel3->sym_ptr_ptr = iname_lab_pp; - } + rel3->sym_ptr_ptr = iname_lab_pp; + } sec->orelocation = rpp; sec->reloc_count = rpp_len - 1; @@ -2581,9 +2586,9 @@ make_one_lib_file (export_type *exp, int i, int delay) rel->address = 0; rel->addend = 0; if (create_for_pep) - rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_64); + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_64); else - rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); + rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_32); rel->sym_ptr_ptr = secdata[TEXT].sympp; sec->orelocation = rpp; break; @@ -2599,7 +2604,7 @@ make_one_lib_file (export_type *exp, int i, int delay) si->data = xmalloc (8); si->size = 8; if (exp->noname) - { + { si->data[0] = exp->ordinal ; si->data[1] = exp->ordinal >> 8; si->data[2] = exp->ordinal >> 16; @@ -2608,9 +2613,9 @@ make_one_lib_file (export_type *exp, int i, int delay) si->data[5] = 0; si->data[6] = 0; si->data[7] = 0x80; - } + } else - { + { sec->reloc_count = 1; memset (si->data, 0, si->size); rel = xmalloc (sizeof (arelent)); @@ -2622,7 +2627,7 @@ make_one_lib_file (export_type *exp, int i, int delay) rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_RVA); rel->sym_ptr_ptr = secdata[IDATA6].sympp; sec->orelocation = rpp; - } + } } else { @@ -2630,14 +2635,14 @@ make_one_lib_file (export_type *exp, int i, int delay) si->size = 4; if (exp->noname) - { + { si->data[0] = exp->ordinal ; si->data[1] = exp->ordinal >> 8; si->data[2] = exp->ordinal >> 16; si->data[3] = 0x80; - } + } else - { + { sec->reloc_count = 1; memset (si->data, 0, si->size); rel = xmalloc (sizeof (arelent)); @@ -2649,7 +2654,7 @@ make_one_lib_file (export_type *exp, int i, int delay) rel->howto = bfd_reloc_type_lookup (abfd, BFD_RELOC_RVA); rel->sym_ptr_ptr = secdata[IDATA6].sympp; sec->orelocation = rpp; - } + } } break; @@ -2661,9 +2666,9 @@ make_one_lib_file (export_type *exp, int i, int delay) in programs compiled with the MS tools. */ int idx = exp->hint; if (exp->its_name) - si->size = strlen (exp->its_name) + 3; + si->size = strlen (exp->its_name) + 3; else - si->size = strlen (xlate (exp->import_name)) + 3; + si->size = strlen (xlate (exp->import_name)) + 3; si->data = xmalloc (si->size); memset (si->data, 0, si->size); si->data[0] = idx & 0xff; @@ -2748,7 +2753,7 @@ make_head (void) fprintf (f, "%s IMAGE_IMPORT_DESCRIPTOR\n", ASM_C); fprintf (f, "\t.section\t.idata$2\n"); - fprintf (f,"\t%s\t%s\n", ASM_GLOBAL, head_label); + fprintf (f, "\t%s\t%s\n", ASM_GLOBAL, head_label); fprintf (f, "%s:\n", head_label); @@ -2774,12 +2779,12 @@ make_head (void) { fprintf (f, "\t.section\t.idata$5\n"); if (use_nul_prefixed_import_tables) - { + { if (create_for_pep) - fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); else - fprintf (f,"\t%s\t0\n", ASM_LONG); - } + fprintf (f, "\t%s\t0\n", ASM_LONG); + } fprintf (f, "fthunk:\n"); } @@ -2787,12 +2792,12 @@ make_head (void) { fprintf (f, "\t.section\t.idata$4\n"); if (use_nul_prefixed_import_tables) - { + { if (create_for_pep) - fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); else - fprintf (f,"\t%s\t0\n", ASM_LONG); - } + fprintf (f, "\t%s\t0\n", ASM_LONG); + } fprintf (f, "hname:\n"); } @@ -2827,7 +2832,7 @@ make_delay_head (void) /* Output the __tailMerge__xxx function */ fprintf (f, "%s Import trampoline\n", ASM_C); fprintf (f, "\t.section\t.text\n"); - fprintf(f,"\t%s\t%s\n", ASM_GLOBAL, head_label); + fprintf (f, "\t%s\t%s\n", ASM_GLOBAL, head_label); if (HOW_SEH) fprintf (f, "\t.seh_proc\t%s\n", head_label); fprintf (f, "%s:\n", head_label); @@ -2838,7 +2843,7 @@ make_delay_head (void) /* Output the delay import descriptor */ fprintf (f, "\n%s DELAY_IMPORT_DESCRIPTOR\n", ASM_C); fprintf (f, ".section\t.text$2\n"); - fprintf (f,"%s __DELAY_IMPORT_DESCRIPTOR_%s\n", ASM_GLOBAL,imp_name_lab); + fprintf (f, "%s __DELAY_IMPORT_DESCRIPTOR_%s\n", ASM_GLOBAL,imp_name_lab); fprintf (f, "__DELAY_IMPORT_DESCRIPTOR_%s:\n", imp_name_lab); fprintf (f, "\t%s 1\t%s grAttrs\n", ASM_LONG, ASM_C); fprintf (f, "\t%s__%s_iname%s\t%s rvaDLLName\n", @@ -2868,9 +2873,9 @@ make_delay_head (void) fprintf (f, "\t.section\t.idata$5\n"); /* NULL terminating list. */ if (create_for_pep) - fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); else - fprintf (f,"\t%s\t0\n", ASM_LONG); + fprintf (f, "\t%s\t0\n", ASM_LONG); fprintf (f, "__IAT_%s:\n", imp_name_lab); } @@ -2879,7 +2884,7 @@ make_delay_head (void) fprintf (f, "\t.section\t.idata$4\n"); fprintf (f, "\t%s\t0\n", ASM_LONG); if (create_for_pep) - fprintf (f, "\t%s\t0\n", ASM_LONG); + fprintf (f, "\t%s\t0\n", ASM_LONG); fprintf (f, "\t.section\t.idata$4\n"); fprintf (f, "__INT_%s:\n", imp_name_lab); } @@ -2918,18 +2923,18 @@ make_tail (void) { fprintf (f, "\t.section\t.idata$4\n"); if (create_for_pep) - fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); else - fprintf (f,"\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ + fprintf (f, "\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ } if (!no_idata5) { fprintf (f, "\t.section\t.idata$5\n"); if (create_for_pep) - fprintf (f,"\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); + fprintf (f, "\t%s\t0\n\t%s\t0\n", ASM_LONG, ASM_LONG); else - fprintf (f,"\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ + fprintf (f, "\t%s\t0\n", ASM_LONG); /* NULL terminating list. */ } fprintf (f, "\t.section\t.idata$7\n"); @@ -3059,7 +3064,7 @@ gen_lib_file (int delay) for (i = 0; (exp = d_exports_lexically[i]); i++) { /* Don't delete non-existent stubs for PRIVATE entries. */ - if (exp->private) + if (exp->private) continue; sprintf (name + stub_len, "%05d.o", i); if (unlink (name) < 0) @@ -3138,7 +3143,7 @@ dll_name_list_print (dll_name_list_type * list) p = list->head; - while (p && p->next && p->next->dllname && *(p->next->dllname)) + while (p && p->next && p->next->dllname && *p->next->dllname) { printf ("%s\n", p->next->dllname); p = p->next; @@ -3233,8 +3238,8 @@ identify_member_contains_symname (bfd * abfd, for (i = 0; i < number_of_symbols; i++) { if (strncmp (symbol_table[i]->name, - search_data->symname, - strlen (search_data->symname)) == 0) + search_data->symname, + strlen (search_data->symname)) == 0) { search_data->found = true; break; @@ -3288,7 +3293,7 @@ identify_dll_for_implib (void) if (! bfd_check_format (abfd, bfd_archive)) { if (! bfd_close (abfd)) - bfd_fatal (identify_imp_name); + bfd_fatal (identify_imp_name); fatal (_("%s is not a library"), identify_imp_name); } @@ -3296,7 +3301,7 @@ identify_dll_for_implib (void) /* Detect if this a Microsoft import library. */ identify_search_archive (abfd, identify_member_contains_symname, - (void *)(& search_data)); + (void *) &search_data); if (search_data.found) identify_data.ms_style_implib = true; @@ -3310,7 +3315,7 @@ identify_dll_for_implib (void) if (!bfd_check_format (abfd, bfd_archive)) { if (!bfd_close (abfd)) - bfd_fatal (identify_imp_name); + bfd_fatal (identify_imp_name); fatal (_("%s is not a library"), identify_imp_name); } @@ -3318,7 +3323,7 @@ identify_dll_for_implib (void) /* Now search for the dll name. */ identify_search_archive (abfd, identify_search_member, - (void *)(& identify_data)); + (void *) &identify_data); if (! bfd_close (abfd)) bfd_fatal (identify_imp_name); @@ -3327,12 +3332,12 @@ identify_dll_for_implib (void) if (count > 0) { if (identify_strict && count > 1) - { - dll_name_list_free (identify_data.list); - identify_data.list = NULL; - fatal (_("Import library `%s' specifies two or more dlls"), + { + dll_name_list_free (identify_data.list); + identify_data.list = NULL; + fatal (_("Import library `%s' specifies two or more dlls"), identify_imp_name); - } + } dll_name_list_print (identify_data.list); dll_name_list_free (identify_data.list); identify_data.list = NULL; @@ -3364,19 +3369,19 @@ identify_search_archive (bfd * abfd, arfile = bfd_openr_next_archived_file (abfd, arfile); if (arfile == NULL) - { - if (bfd_get_error () != bfd_error_no_more_archived_files) - bfd_fatal (bfd_get_filename (abfd)); - break; - } + { + if (bfd_get_error () != bfd_error_no_more_archived_files) + bfd_fatal (bfd_get_filename (abfd)); + break; + } if (bfd_check_format_matches (arfile, bfd_object, &matching)) (*operation) (arfile, abfd, user_storage); else - { - bfd_nonfatal (bfd_get_filename (arfile)); - free (matching); - } + { + bfd_nonfatal (bfd_get_filename (arfile)); + free (matching); + } if (last_arfile != NULL) { @@ -3481,7 +3486,7 @@ identify_search_section (bfd * abfd, asection * section, void * obj) name begins at offset 0 in the data. We assume that the dll name does not contain unprintable characters. */ if (data[0] != '\0' && ISPRINT (data[0]) - && ((datasize < 2) || ISPRINT (data[1]))) + && (datasize < 2 || ISPRINT (data[1]))) dll_name_list_append (identify_data->list, data); free (data); @@ -3574,7 +3579,7 @@ process_duplicates (export_type **d_export_vec) && b->ordinal != -1) /* xgettext:c-format */ fatal (_("Error, duplicate EXPORT with ordinals: %s"), - a->name); + a->name); /* Merge attributes. */ b->ordinal = a->ordinal > 0 ? a->ordinal : b->ordinal; @@ -3855,9 +3860,9 @@ main (int ac, char **av) while ((c = getopt_long (ac, av, #ifdef DLLTOOL_MCORE_ELF - "m:e:l:aD:d:z:b:xp:cCuUkAS:t:f:nI:vVHhM:L:F:", + "m:e:l:aD:d:z:b:xp:cCuUkAS:t:f:nI:vVHhM:L:F:", #else - "m:e:l:y:aD:d:z:b:xp:cCuUkAS:t:f:nI:vVHh", + "m:e:l:y:aD:d:z:b:xp:cCuUkAS:t:f:nI:vVHh", #endif long_options, 0)) != EOF) @@ -3923,7 +3928,7 @@ main (int ac, char **av) dll_name = (char*) lbasename (optarg); if (dll_name != optarg) non_fatal (_("Path components stripped from dllname, '%s'."), - optarg); + optarg); break; case 'l': imp_name = optarg; @@ -4013,24 +4018,22 @@ main (int ac, char **av) machine = i; /* Check if we generated PE+. */ - create_for_pep = strcmp (mname, "i386:x86-64") == 0 || - strcmp (mname, "arm64") == 0; + create_for_pep = (strcmp (mname, "i386:x86-64") == 0 + || strcmp (mname, "arm64") == 0); - { - /* Check the default underscore */ - int u = leading_underscore; /* Underscoring mode. -1 for use default. */ - if (u == -1) - bfd_get_target_info (mtable[machine].how_bfd_target, NULL, - NULL, &u, NULL); - if (u != -1) - leading_underscore = u != 0; - } + /* Check the default underscore */ + int u = leading_underscore; /* Underscoring mode. -1 for use default. */ + if (u == -1) + bfd_get_target_info (mtable[machine].how_bfd_target, NULL, + NULL, &u, NULL); + if (u != -1) + leading_underscore = u != 0; if (!dll_name && exp_name) { /* If we are inferring dll_name from exp_name, - strip off any path components, without emitting - a warning. */ + strip off any path components, without emitting + a warning. */ const char* exp_basename = lbasename (exp_name); const int len = strlen (exp_basename) + 5; dll_name = xmalloc (len); @@ -4066,18 +4069,18 @@ main (int ac, char **av) { /* If possible use a deterministic prefix. */ if (imp_name || delayimp_name) - { - const char *input = imp_name ? imp_name : delayimp_name; - tmp_prefix = xmalloc (strlen (input) + 2); - sprintf (tmp_prefix, "%s_", input); - for (i = 0; tmp_prefix[i]; i++) - if (!ISALNUM (tmp_prefix[i])) - tmp_prefix[i] = '_'; - } + { + const char *input = imp_name ? imp_name : delayimp_name; + tmp_prefix = xmalloc (strlen (input) + 2); + sprintf (tmp_prefix, "%s_", input); + for (i = 0; tmp_prefix[i]; i++) + if (!ISALNUM (tmp_prefix[i])) + tmp_prefix[i] = '_'; + } else - { - tmp_prefix = prefix_encode ("d", getpid ()); - } + { + tmp_prefix = prefix_encode ("d", getpid ()); + } } mangle_defs (); @@ -4106,23 +4109,23 @@ main (int ac, char **av) char *p; if (mtable[machine].how_dljtab == 0) - { - inform (_("Warning, machine type (%d) not supported for " - "delayimport."), machine); - } + { + inform (_("Warning, machine type (%d) not supported for " + "delayimport."), machine); + } else - { - killat = 1; - imp_name = delayimp_name; - imp_name_lab = xstrdup (imp_name); - for (p = imp_name_lab; *p; p++) - { - if (!ISALNUM (*p)) - *p = '_'; - } - head_label = make_label("__tailMerge_", imp_name_lab); - gen_lib_file (1); - } + { + killat = 1; + imp_name = delayimp_name; + imp_name_lab = xstrdup (imp_name); + for (p = imp_name_lab; *p; p++) + { + if (!ISALNUM (*p)) + *p = '_'; + } + head_label = make_label("__tailMerge_", imp_name_lab); + gen_lib_file (1); + } } if (output_def) @@ -4240,14 +4243,14 @@ deduce_name (const char *prog_name) if (dash != NULL) { /* First, try looking for a prefixed PROG_NAME in the - PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME. */ + PROGRAM_NAME directory, with the same prefix as PROGRAM_NAME. */ cmd = look_for_prog (prog_name, program_name, dash - program_name + 1); } if (slash != NULL && cmd == NULL) { /* Next, try looking for a PROG_NAME in the same directory as - that of this program. */ + that of this program. */ cmd = look_for_prog (prog_name, program_name, slash - program_name + 1); } |