[PECOFF] Fix /include option in .drectve section.
authorRui Ueyama <ruiu@google.com>
Mon, 4 Aug 2014 23:48:57 +0000 (23:48 +0000)
committerRui Ueyama <ruiu@google.com>
Mon, 4 Aug 2014 23:48:57 +0000 (23:48 +0000)
commit145ef0186c3e53365127f4e72af2e617c4d8ef90
tree68a557ee0a326c277f9595782596e3c558b873ac
parentf490bec4a1356a0d3f8269eae5cb2c7cbcd3174e
[PECOFF] Fix /include option in .drectve section.

/INCLUDE arguments passed as command line options are handled in the
same way as Unix -u. All option values are converted to an undefined
symbol and added to a dummy input file, so that the specified symbols
are resolved.

One tricky thing on Windows is that the option is also allowed to
appear in the object file's directive section. At the time when
it's being read, all (regular) command line options have already
been processed. We cannot add undefined atoms to the dummy file
anymore.

Previously, we added such /INCLUDE to a set that has already been
processed. As a result the options were ignored.

This patch fixes the issue. Now, /INCLUDE symbols in the directive
section are handled as real undefined symbol in the COFF file.
We create an undefined symbol for each /INCLUDE argument and add
it to the file being parsed.

llvm-svn: 214824
lld/include/lld/Driver/Driver.h
lld/lib/Driver/WinLinkDriver.cpp
lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
lld/test/pecoff/Inputs/drectve2.obj.yaml [new file with mode: 0644]
lld/test/pecoff/drectve.test