From: Luke D. <cod...@ho...> - 2003-03-12 11:47:21
|
Danny, I was going to reply about your suggested patch but then I decided to let the binutils mailing list (which I am not subscribed to) deal with it, but I'm still not sure about it. >However, I admit that I not know enough about how this will affect parsing >of LIBRARY or NAME commands. With this patch, the special treatment of '.' >in opt_name appears to be redundant. > >My tests with LIBRARY or NAME commands in def files for windows targets >have succeeded with this patch. What am I missing? I agree that this change would remove the need for opt_name, so I think that the redundant rules should be removed because otherwise the parser becomes confusing. However, I believe that the patch breaks the handling of the "IMPORTS" section, but I wasn't even aware of such a section until now so I'm not sure of its purpose. I also haven't found any useful MSDN documentation on this section except a little about 16-bit apps. Here are the rules: impline: ID '=' ID '.' ID '.' ID { def_import ($1, $3, $5, $7, -1); } | ID '=' ID '.' ID '.' NUMBER { def_import ($1, $3, $5, 0, $7); } | ID '=' ID '.' ID { def_import ($1, $3, 0, $5, -1); } | ID '=' ID '.' NUMBER { def_import ($1, $3, 0, 0, $5); } | ID '.' ID '.' ID { def_import ( 0, $1, $3, $5, -1); } | ID '.' ID { def_import ( 0, $1, 0, $3, -1); } ; The def_import() function does just concatenate the module name and the DLL's file extension in the first two cases, but the patch will prevent the parser from distinguishing the function name (the last ID) from the DLL name. Some possible solutions (instead of the patch): 1. Define a "dotted_name" rule that parses an ID followed by any number of dots and IDs, then concatenates them. The dotted_name would replace ID in only "expline" and "opt_equal_name". 2. Use a "lexical tie-in" to temporarily set a flag in the parser that tells the lexer to treat '.' as part of an ID. 3. Insert quotes around the param of the -export directive in def_file_add_directive(). This would handle dllimport and --export-all but in theory a problematic .def file might be specified manually on the command line. If the IMPORTS section doesn't need to be supported in binutils anyway then that would be easy, but if it does then I guess there should be a test case, if we can find an example of its use. Other sections like "SECTIONS" are probably obsolete too. BTW, MSVC 6 generates something like this for an unnamed namespace, and processes it like any other export: ?foo@?%C:\devl\test\dlltest\dlltest.cpp42368689@@YAXXZ Luke _________________________________________________________________ MSN Instant Messenger now available on Australian mobile phones. Go to http://ninemsn.com.au/mobilecentral/hotmail_messenger.asp |