[patch ld/dlltool]: Allow empty LIBRARY statement in .def file

Kai Tietz ktietz70@googlemail.com
Wed Jul 25 23:15:00 GMT 2012


2012/7/26 Christopher Faylor <cgf-use-the-mailinglist-please@sourceware.org>:
> On Wed, Jul 25, 2012 at 11:13:02PM +0200, Kai Tietz wrote:
>>Hi,
>>
>>this patch relax behavior of dlltool and ld about .def file parsing so
>>that the name of LIBRARY statement is optional.
>>
>>ChangeLog
>>
>>binutils/
>>2012-07-25  Kai Tietz
>>
>>        * defparse.y (command): Call def_library only if name isn't
>>NULL and not empty.
>>
>>ld/
>>
>>2012-07-25  Kai Tietz
>>
>>        * deffilep.y (command): Call def_image_name only if name isn't
>>NULL and not empty.
>>
>>Regression tested for x86_64-w64-mingw32, i686-w64-mingw32, and
>>i686-pc-cygwin.  ok for apply?
>>
>>Regards,
>>Kai
>>
>>Index: defparse.y
>>===================================================================
>>RCS file: /cvs/src/src/binutils/defparse.y,v
>>retrieving revision 1.14
>>diff -u -r1.14 defparse.y
>>--- defparse.y  24 Feb 2012 14:20:16 -0000      1.14
>>+++ defparse.y  25 Jul 2012 20:56:31 -0000
>>@@ -52,7 +52,12 @@
>>
>> command:
>>                NAME opt_name opt_base { def_name ($2, $3); }
>>-       |       LIBRARY opt_name opt_base option_list { def_library ($2, $3); }
>>+       |       LIBRARY opt_name opt_base option_list
>>+               {
>>+                 /* Ignore LIBRARY without argument, or empty name.  */
>>+                 if ($2 && $2[0] != 0)
>>+                   def_library ($2, $3);
>>+               }
>
> It seems like def_library() is also making decisions based on its first
> parameter.  This test will short-circuit those tests.  It seems like
> either this should all be handled in def_library or the tests in
> def_library() should be deleted.

Yes, you are right. I think best way here is to remove the
useless-code paths in def_library caused by this patch. In fact logic
in def_library depends on valid name-argument, so the short-circuit we
can do also in this function.

I'll prepare a patch for this.

Regards,
Kai



More information about the Binutils mailing list