This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Improve correctness of def parsing for GNU features
ClosedPublic

Authored by mstorsjo on Apr 30 2018, 12:50 AM.

Details

Summary

The operator == used for exporting a function with a different name in the DLL compared to the name in the import library (which is useful for adding linker level aliases for function in the import library) is a feature distinct and different from the operator = used for exporting a function with a different name (both in import library and DLL) than in the implementation producing the DLL.

When creating an import library using dlltool, from a def file that contains forwards (Func = OtherDll.Func), this shouldn't affect the produced import library, which should still behave just as if it was a normal exported function.

This clears a lot of confusion and subtle misunderstandings, and avoids a parameter that was used to avoid creating weak aliases when invoked from lld. (This parameter was added previously due to the existing conflation of the two features.)

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Apr 30 2018, 12:50 AM

As a reference to resolve this misconception, GNU ld's manual has got the following grammar for the def files:

EXPORTS
  ( (  ( <name1> [ = <name2> ] )
     | ( <name1> = <module-name> . <external-name>))
  [ @ <integer> ] [NONAME] [DATA] [CONSTANT] [PRIVATE] [== <name3>] ) *

(From https://sourceware.org/binutils/docs-2.29/ld/WIN32.html.) So both = and == do exist in GNU tools, but meaning different things.

rnk accepted this revision.May 8 2018, 3:37 PM

lgtm

This revision is now accepted and ready to land.May 8 2018, 3:37 PM
This revision was automatically updated to reflect the committed changes.