This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFH] About dlltool --output-exp --add-indirect.


I am looking at fixing the underscore usage in dlltool for arm-wince-pe,
but I see something I don't understand:

What is the --add-indirect option used for? I see that it puts the _imp_<symbol> on the export table,
but what is it that used for?


Here is a snippet of the dlltool.c:gen_exp_file, where --add-indirect is handled:

 /* Add to the output file a way of getting to the exported names
    without using the import library.  */
 if (add_indirect)
   {
     fprintf (f, "\t.section\t.rdata\n");
     for (i = 0, exp = d_exports; exp; i++, exp = exp->next)
   if (!exp->noname || show_allnames)
     {
       /* We use a single underscore for MS compatibility, and a
              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\n", ASM_GLOBAL, exp->name);
       if (create_compat_implib)
         fprintf (f, "__imp_%s:\n", exp->name);
       fprintf (f, "_imp__%s:\n", exp->name);
       fprintf (f, "\t%s\t%s\n", ASM_LONG, exp->name);
     }
   }

How can this be right? Since we are outputting assembly, isn't there an underscore missing in the left of all those _imp_ ?
In ld/pe-dll.c, if the target is underscored (cygwin/mingw), we use __imp_ by default, and add an ___imp_ alias
if compatibility with older cygwin releases is requested. From what I see with MSVC, __imp_ is indeed the correct
import prefix.
From what I can find on the web, an exp file is a normal coff object/bfd with the only the .edata section of the image.


Anyone has an idea how to generate the equivalent of --add-indirect with MSFT's link.exe?
Also, does anyone use this option nowadays?


Oh, and --add-indirect docs on dlltool's manual has the funniest comment I could find on binutils.

<quoting>
--add-indirect
Specifies that when dlltool is creating the exports file it should add a section which allows the exported functions
to be referenced without using the import library. Whatever the hell that means!
</quoting>


Cheers,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]