From ada0f6a93e1308d9d756ecd29fb86f4e8ad57d96 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 4 Jul 2014 15:03:17 +0000 Subject: [PATCH] Don't include llvm.metadata variables in archive symbol tables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212344 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Object/IRObjectFile.cpp | 5 +++++ test/Object/Inputs/trivial.ll | 3 +++ test/Object/nm-archive.test | 1 + 3 files changed, 9 insertions(+) diff --git a/lib/Object/IRObjectFile.cpp b/lib/Object/IRObjectFile.cpp index 50394058a87..d01910811a6 100644 --- a/lib/Object/IRObjectFile.cpp +++ b/lib/Object/IRObjectFile.cpp @@ -240,6 +240,11 @@ uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const { if (GV->hasLinkOnceLinkage() || GV->hasWeakLinkage()) Res |= BasicSymbolRef::SF_Weak; + if (auto *Var = dyn_cast(GV)) { + if (Var->getSection() == StringRef("llvm.metadata")) + Res |= BasicSymbolRef::SF_FormatSpecific; + } + return Res; } diff --git a/test/Object/Inputs/trivial.ll b/test/Object/Inputs/trivial.ll index 25ece7611a3..622d1e97f1e 100644 --- a/test/Object/Inputs/trivial.ll +++ b/test/Object/Inputs/trivial.ll @@ -10,3 +10,6 @@ entry: declare i32 @puts(i8* nocapture) nounwind declare void @SomeOtherFunction(...) + +@var = global i32 0 +@llvm.used = appending global [1 x i8*] [i8* bitcast (i32* @var to i8*)], section "llvm.metadata" diff --git a/test/Object/nm-archive.test b/test/Object/nm-archive.test index d875d6c991c..9cb84b28d29 100644 --- a/test/Object/nm-archive.test +++ b/test/Object/nm-archive.test @@ -18,6 +18,7 @@ RUN: llvm-nm %t2 | FileCheck %s -check-prefix BITCODE BITCODE: U SomeOtherFunction BITCODE-NEXT: T main BITCODE-NEXT: U puts +BITCODE-NEXT: D var Test we don't error with an archive with no symtab.