summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmy Huang <akhuang@google.com>2019-09-12 22:04:56 +0000
committerAmy Huang <akhuang@google.com>2019-09-12 22:04:56 +0000
commit227d85956b205a60a9fa7b269854f0da0653da29 (patch)
tree784081f13b34a971eded1bd60d1b44985ba34765
parent0e8d5085ac8143c249b082f58a96a1523009633c (diff)
downloadbcm5719-llvm-227d85956b205a60a9fa7b269854f0da0653da29.tar.gz
bcm5719-llvm-227d85956b205a60a9fa7b269854f0da0653da29.zip
[COFF] Fix to not add archive name to buffer identifiers when they come
from thin archives. Currently lld adds the archive name to MemoryBufferRef identifiers in order to ensure they are unique. For thin archives, since the file name is already unique and we want to keep the original path to the file, don't add the archive name. Differential Revision: https://reviews.llvm.org/D67295 llvm-svn: 371778
-rw-r--r--lld/COFF/Driver.cpp5
-rw-r--r--lld/test/COFF/thinlto-index-only.ll11
2 files changed, 14 insertions, 2 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 882313a18bf..b4457333eb5 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -310,9 +310,10 @@ void LinkerDriver::enqueueArchiveMember(const Archive::Child &c,
auto mbOrErr = future->get();
if (mbOrErr.second)
reportBufferError(errorCodeToError(mbOrErr.second), childName);
+ // Pass empty string as archive name so that the original filename is
+ // used as the buffer identifier.
driver->addArchiveBuffer(takeBuffer(std::move(mbOrErr.first)),
- toCOFFString(sym), parentName,
- /*OffsetInArchive=*/0);
+ toCOFFString(sym), "", /*OffsetInArchive=*/0);
});
}
diff --git a/lld/test/COFF/thinlto-index-only.ll b/lld/test/COFF/thinlto-index-only.ll
index db41309d83d..996c888cbe2 100644
--- a/lld/test/COFF/thinlto-index-only.ll
+++ b/lld/test/COFF/thinlto-index-only.ll
@@ -41,6 +41,17 @@
; BACKEND2-NEXT: <COMBINED
; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK
+; Thin archive tests. Check that the module paths point to the original files.
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: opt -thinlto-bc -o %t/foo.obj < %s
+; RUN: opt -thinlto-bc -o %t/bar.obj < %p/Inputs/thinlto.ll
+; RUN: llvm-ar rcsT %t5.lib %t/bar.obj %t3.obj
+; RUN: lld-link -thinlto-index-only -entry:main %t/foo.obj %t5.lib
+; RUN: llvm-dis -o - %t/foo.obj.thinlto.bc | FileCheck %s --check-prefix=THINARCHIVE
+; THINARCHIVE: ^0 = module: (path: "{{.*}}foo.obj",
+; THINARCHIVE: ^1 = module: (path: "{{.*}}bar.obj",
+
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.0.24215"
OpenPOWER on IntegriCloud