From: Rui Ueyama Date: Fri, 27 Feb 2015 23:15:11 +0000 (+0000) Subject: Call File::beforeLink hook even if the file is in an archive. X-Git-Tag: llvmorg-3.7.0-rc1~10612 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c817fd22735b1b7b84855dd3fc462b26aca1747e;p=platform%2Fupstream%2Fllvm.git 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. llvm-svn: 230808 --- diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 58b751a..61913f9 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -79,6 +79,7 @@ bool Resolver::handleArchiveFile(const File &file) { [&](StringRef undefName, bool dataSymbolOnly) { if (const File *member = archiveFile->find(undefName, dataSymbolOnly)) { member->setOrdinal(_context.getNextOrdinalAndIncrement()); + const_cast(member)->beforeLink(); undefAdded = handleFile(*member) || undefAdded; } }); diff --git a/lld/test/pecoff/Inputs/drectve3.lib b/lld/test/pecoff/Inputs/drectve3.lib new file mode 100644 index 0000000..c295d1f Binary files /dev/null and b/lld/test/pecoff/Inputs/drectve3.lib differ diff --git a/lld/test/pecoff/drectve.test b/lld/test/pecoff/drectve.test index a471206..258f608 100644 --- a/lld/test/pecoff/drectve.test +++ b/lld/test/pecoff/drectve.test @@ -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