summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-06-23 11:31:32 +0000
committerDaniel Jasper <djasper@google.com>2015-06-23 11:31:32 +0000
commit41de8027b1f744c1e52f54ca9a1b120c7fda81af (patch)
tree38c65f7deacbb6c2e627a040d4284143473442a8 /llvm/lib/MC
parent6d9be8e771bd058ae513a89bd7932fa4b2aaddc6 (diff)
downloadbcm5719-llvm-41de8027b1f744c1e52f54ca9a1b120c7fda81af.tar.gz
bcm5719-llvm-41de8027b1f744c1e52f54ca9a1b120c7fda81af.zip
Revert r240302 ("Bring r240130 back.").
This causes errors like: ld: error: blah.o: requires dynamic R_X86_64_PC32 reloc against '' which may overflow at runtime; recompile with -fPIC blah.cc:function f(): error: undefined reference to '' blah.o:g(): error: undefined reference to '' I have not yet come up with an appropriate reproduction. llvm-svn: 240394
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp13
-rw-r--r--llvm/lib/MC/MCContext.cpp28
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp3
3 files changed, 19 insertions, 25 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 71d3f86d9e6..db9c759f2b5 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -787,15 +787,10 @@ void ELFObjectWriter::computeSymbolTable(
Renames.count(&Symbol)))
continue;
- if (Symbol.isTemporary() && Symbol.isUndefined())
- Ctx.reportFatalError(SMLoc(), "Undefined temporary");
-
ELFSymbolData MSD;
MSD.Symbol = cast<MCSymbolELF>(&Symbol);
bool Local = Symbol.getBinding() == ELF::STB_LOCAL;
- assert(Local || !Symbol.isTemporary());
-
if (Symbol.isAbsolute()) {
MSD.SectionIndex = ELF::SHN_ABS;
} else if (Symbol.isCommon()) {
@@ -894,11 +889,9 @@ void ELFObjectWriter::computeSymbolTable(
unsigned Index = FileNames.size() + 1;
for (ELFSymbolData &MSD : LocalSymbolData) {
- unsigned StringIndex;
- if (MSD.Symbol->getType() == ELF::STT_SECTION || MSD.Name.empty())
- StringIndex = 0;
- else
- StringIndex = StrTabBuilder.getOffset(MSD.Name);
+ unsigned StringIndex = MSD.Symbol->getType() == ELF::STT_SECTION
+ ? 0
+ : StrTabBuilder.getOffset(MSD.Name);
MSD.Symbol->setIndex(Index++);
writeSymbol(Writer, StringIndex, MSD, Layout);
}
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 01074eb5e79..c601c56f395 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -116,7 +116,7 @@ MCSymbol *MCContext::getOrCreateSymbol(const Twine &Name) {
MCSymbol *&Sym = Symbols[NameRef];
if (!Sym)
- Sym = createSymbol(NameRef, false);
+ Sym = createSymbol(NameRef, false, false);
return Sym;
}
@@ -175,16 +175,17 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
IsTemporary);
}
-MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix) {
+MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
+ bool CanBeUnnamed) {
+ if (CanBeUnnamed && !UseNamesOnTempLabels)
+ return createSymbolImpl(nullptr, true);
+
// Determine whether this is an user writter assembler temporary or normal
// label, if used.
- bool IsTemporary = false;
- if (AllowTemporaryLabels)
+ bool IsTemporary = CanBeUnnamed;
+ if (AllowTemporaryLabels && !IsTemporary)
IsTemporary = Name.startswith(MAI->getPrivateGlobalPrefix());
- if (IsTemporary && !UseNamesOnTempLabels)
- return createSymbolImpl(nullptr, true);
-
SmallString<128> NewName = Name;
bool AddSuffix = AlwaysAddSuffix;
unsigned &NextUniqueID = NextID[Name];
@@ -205,20 +206,21 @@ MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix) {
llvm_unreachable("Infinite loop");
}
-MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix) {
+MCSymbol *MCContext::createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
+ bool CanBeUnnamed) {
SmallString<128> NameSV;
raw_svector_ostream(NameSV) << MAI->getPrivateGlobalPrefix() << Name;
- return createSymbol(NameSV, AlwaysAddSuffix);
+ return createSymbol(NameSV, AlwaysAddSuffix, CanBeUnnamed);
}
MCSymbol *MCContext::createLinkerPrivateTempSymbol() {
SmallString<128> NameSV;
raw_svector_ostream(NameSV) << MAI->getLinkerPrivateGlobalPrefix() << "tmp";
- return createSymbol(NameSV, true);
+ return createSymbol(NameSV, true, false);
}
-MCSymbol *MCContext::createTempSymbol() {
- return createTempSymbol("tmp", true);
+MCSymbol *MCContext::createTempSymbol(bool CanBeUnnamed) {
+ return createTempSymbol("tmp", true, CanBeUnnamed);
}
unsigned MCContext::NextInstance(unsigned LocalLabelVal) {
@@ -239,7 +241,7 @@ MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
unsigned Instance) {
MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
if (!Sym)
- Sym = createTempSymbol();
+ Sym = createTempSymbol(false);
return Sym;
}
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index d7934ad80c6..8ce6127e386 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -565,8 +565,7 @@ void MachObjectWriter::computeSymbolTable(
MachSymbolData MSD;
MSD.Symbol = &Symbol;
- StringRef Name = Symbol.getName();
- MSD.StringIndex = Name.empty() ? 0 : StringTable.getOffset(Name);
+ MSD.StringIndex = StringTable.getOffset(Symbol.getName());
if (Symbol.isAbsolute()) {
MSD.SectionIndex = 0;
OpenPOWER on IntegriCloud