[lld] r230808 - Call File::beforeLink hook even if the file is in an archive.
Rui Ueyama
ruiu at google.com
Fri Feb 27 15:15:11 PST 2015
Author: ruiu
Date: Fri Feb 27 17:15:11 2015
New Revision: 230808
URL: http://llvm.org/viewvc/llvm-project?rev=230808&view=rev
Log:
Call File::beforeLink hook even if the file is in an archive.
Previously we didn't call the hook on a file in an archive, which
let the PE/COFF port fail to link files in archives. It was a
simple mistake. Added a call to the hook and also added a test to
catch that error.
const_cast is an unfortunate hack. Files in the resolver are usually
const, but they are not actually const objects, since they are
mutated if either a file is taken from an archive (an archive file
does never return the same file twice) or the beforeLink hook is
called. Maybe we should just remove const from there -- because they
are not const.
Added:
lld/trunk/test/pecoff/Inputs/drectve3.lib
Modified:
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/test/pecoff/drectve.test
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=230808&r1=230807&r2=230808&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Fri Feb 27 17:15:11 2015
@@ -79,6 +79,7 @@ bool Resolver::handleArchiveFile(const F
[&](StringRef undefName, bool dataSymbolOnly) {
if (const File *member = archiveFile->find(undefName, dataSymbolOnly)) {
member->setOrdinal(_context.getNextOrdinalAndIncrement());
+ const_cast<File *>(member)->beforeLink();
undefAdded = handleFile(*member) || undefAdded;
}
});
Added: lld/trunk/test/pecoff/Inputs/drectve3.lib
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/drectve3.lib?rev=230808&view=auto
==============================================================================
Binary files lld/trunk/test/pecoff/Inputs/drectve3.lib (added) and lld/trunk/test/pecoff/Inputs/drectve3.lib Fri Feb 27 17:15:11 2015 differ
Modified: lld/trunk/test/pecoff/drectve.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/drectve.test?rev=230808&r1=230807&r2=230808&view=diff
==============================================================================
--- lld/trunk/test/pecoff/drectve.test (original)
+++ lld/trunk/test/pecoff/drectve.test Fri Feb 27 17:15:11 2015
@@ -27,6 +27,13 @@ ERROR-NOT: foo
# drectve2.obj contains "/include:foo".
# RUN: yaml2obj %p/Inputs/drectve2.obj.yaml > %t2.obj
# RUN: not lld -flavor link /out:%t2.exe /entry:main -- %t2.obj >& %t2.log
-# RUN: FileCheck -check-prefix=UNDEF %s < %t2.log
+# RUN: FileCheck -check-prefix=UNDEF2 %s < %t2.log
-UNDEF: Undefined symbol: {{.*}}: foo
+UNDEF2: Undefined symbol: {{.*}}: foo
+
+# drectve4.lib contains "/include:bar".
+# RUN: not lld -flavor link /force /out:%t3.exe /entry:main /include:_fn1 -- \
+# RUN: %t2.obj %p/Inputs/drectve3.lib >& %t3.log
+# RUN: FileCheck -check-prefix=UNDEF3 %s < %t3.log
+
+UNDEF3: Undefined symbol: {{.*}}: bar
More information about the llvm-commits
mailing list