diff options
author | Kai Tietz <kai.tietz@onevision.com> | 2009-10-23 11:40:17 +0000 |
---|---|---|
committer | Kai Tietz <kai.tietz@onevision.com> | 2009-10-23 11:40:17 +0000 |
commit | 7fcab871034a5e755786062826456863ab65683b (patch) | |
tree | 6f9c5ce538e5ad88f6985fe18ca50075ee5ac59a /ld/pe-dll.c | |
parent | 424908eba6008ba81a554c062a185f02c15bdc79 (diff) | |
download | fsf-binutils-gdb-7fcab871034a5e755786062826456863ab65683b.zip fsf-binutils-gdb-7fcab871034a5e755786062826456863ab65683b.tar.gz fsf-binutils-gdb-7fcab871034a5e755786062826456863ab65683b.tar.bz2 |
2009-10-23 Kai Tietz <kai.tietz@onevision.com>
* deffile.h (def_file_export): New member its_name.
(def_file_import): Likewise.
(def_file_add_export): Add argument its_name.
(def_file_add_import): Likewise.
* deffilep.y (def_exports): Add argument its_name.
(def_import): Likewise.
(EQUAL): Add new token for '=='.
(opt_equalequal_name): New rule.
(expline): Add rule opt_equalequal_name.
(impline): Likewise.
(def_file_free): Free for exports and imports
the optional member its_name.
(def_lex): Add scan of '==' as EQUAL.
* pe-dll.c (pe_export_sort): Sort for its_name too.
(process_def_file_and_drectve): Adjust calls to
def_file_add_export.
(generate_edata): Take its_name in account.
(make_one): Likewise.
(pe_process_import_defs): Likewise.
(pe_dll_generate_def_file): Add print of new '==' option.
* ld.texinfo: Extend documentation about .def file syntax.
* NEWS: Mention new feature.
Diffstat (limited to 'ld/pe-dll.c')
-rw-r--r-- | ld/pe-dll.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/ld/pe-dll.c b/ld/pe-dll.c index ce5d6a3..dbf1b5e 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -442,8 +442,14 @@ pe_export_sort (const void *va, const void *vb) { const def_file_export *a = va; const def_file_export *b = vb; - - return strcmp (a->name, b->name); + char *an = a->name; + char *bn = b->name; + if (a->its_name) + an = a->its_name; + if (b->its_name) + bn = b->its_name; + + return strcmp (an, bn); } /* Read and process the .DEF file. */ @@ -732,7 +738,7 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info * if (auto_export (b, pe_def_file, sn)) { def_file_export *p; - p=def_file_add_export (pe_def_file, sn, 0, -1); + p=def_file_add_export (pe_def_file, sn, 0, -1, NULL); /* Fill data flag properly, from dlltool.c. */ p->flag_data = !(symbols[j]->flags & BSF_FUNCTION); } @@ -788,7 +794,7 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info * if (auto_export (NULL, pe_def_file, tmp)) def_file_add_export (pe_def_file, tmp, pe_def_file->exports[i].internal_name, - -1); + -1, NULL); else free (tmp); } @@ -1049,7 +1055,10 @@ generate_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED) } exported_symbols[ei] = i; } - name_table_size += strlen (pe_def_file->exports[i].name) + 1; + if (pe_def_file->exports[i].its_name) + name_table_size += strlen (pe_def_file->exports[i].its_name) + 1; + else + name_table_size += strlen (pe_def_file->exports[i].name) + 1; } /* Reserve space for the forward name. */ @@ -1195,6 +1204,8 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED) if (!pe_def_file->exports[s].flag_noname) { char *ename = pe_def_file->exports[s].name; + if (pe_def_file->exports[s].its_name) + ename = pe_def_file->exports[s].its_name; bfd_put_32 (abfd, ERVA (enamestr), enameptrs); enameptrs += 4; @@ -1677,6 +1688,12 @@ pe_dll_generate_def_file (const char *pe_out_def_filename) else fprintf (out, "%d", im->ordinal); + if (im->its_name) + { + fprintf (out, " == "); + quoteput (im->its_name, out, 0); + } + fprintf (out, "\n"); } } @@ -2183,7 +2200,10 @@ make_one (def_file_export *exp, bfd *parent, bfd_boolean include_jmp_stub) else { /* { short, asciz } */ - len = 2 + strlen (exp->name) + 1; + if (exp->its_name) + len = 2 + strlen (exp->its_name) + 1; + else + len = 2 + strlen (exp->name) + 1; if (len & 1) len++; bfd_set_section_size (abfd, id6, len); @@ -2192,7 +2212,10 @@ make_one (def_file_export *exp, bfd *parent, bfd_boolean include_jmp_stub) memset (d6, 0, len); d6[0] = exp->hint & 0xff; d6[1] = exp->hint >> 8; - strcpy ((char *) d6 + 2, exp->name); + if (exp->its_name) + strcpy ((char*) d6 + 2, exp->its_name); + else + strcpy ((char *) d6 + 2, exp->name); } bfd_set_symtab (abfd, symtab, symptr); @@ -2827,6 +2850,7 @@ pe_process_import_defs (bfd *output_bfd, struct bfd_link_info *link_info) } exp.internal_name = pe_def_file->imports[i].internal_name; exp.name = pe_def_file->imports[i].name; + exp.its_name = pe_def_file->imports[i].its_name; exp.ordinal = pe_def_file->imports[i].ordinal; exp.hint = exp.ordinal >= 0 ? exp.ordinal : 0; exp.flag_private = 0; @@ -3057,7 +3081,7 @@ pe_implied_import_dll (const char *filename) || (func_rva >= bss_start && func_rva < bss_end); imp = def_file_add_import (pe_def_file, erva + name_rva, - dll_name, i, 0); + dll_name, i, 0, NULL); /* Mark symbol type. */ imp->data = is_data; |