summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-15 21:56:50 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-15 21:56:50 +0000
commitfe8d866fc75f84119e5ff334c46e4e1262d4b617 (patch)
tree4f2aca2c17eba7291823754e97c0beeaad7cd83c /llvm/lib
parent232dc953ac850f7206b43de53192eff75487b1f8 (diff)
downloadbcm5719-llvm-fe8d866fc75f84119e5ff334c46e4e1262d4b617.tar.gz
bcm5719-llvm-fe8d866fc75f84119e5ff334c46e4e1262d4b617.zip
MC/Mach-O/x86_64: Temporary labels in cstring sections require symbols (and external relocations, but we don't have x86_64 relocations yet).
llvm-svn: 98583
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp10
-rw-r--r--llvm/lib/Target/X86/X86AsmBackend.cpp30
2 files changed, 36 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 0d00ed17525..4cf8b7e522b 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -674,7 +674,10 @@ public:
const MCSymbol &Symbol = it->getSymbol();
// Ignore assembler temporaries.
- if (it->getSymbol().isTemporary())
+ if (it->getSymbol().isTemporary() &&
+ (!it->getFragment() ||
+ !Asm.getBackend().doesSectionRequireSymbols(
+ it->getFragment()->getParent()->getSection())))
continue;
if (!it->isExternal() && !Symbol.isUndefined())
@@ -710,7 +713,10 @@ public:
const MCSymbol &Symbol = it->getSymbol();
// Ignore assembler temporaries.
- if (it->getSymbol().isTemporary())
+ if (it->getSymbol().isTemporary() &&
+ (!it->getFragment() ||
+ !Asm.getBackend().doesSectionRequireSymbols(
+ it->getFragment()->getParent()->getSection())))
continue;
if (it->isExternal() || Symbol.isUndefined())
diff --git a/llvm/lib/Target/X86/X86AsmBackend.cpp b/llvm/lib/Target/X86/X86AsmBackend.cpp
index 88cc2c734bc..a44afc6984d 100644
--- a/llvm/lib/Target/X86/X86AsmBackend.cpp
+++ b/llvm/lib/Target/X86/X86AsmBackend.cpp
@@ -9,6 +9,7 @@
#include "llvm/Target/TargetAsmBackend.h"
#include "X86.h"
+#include "llvm/MC/MCSectionMachO.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetAsmBackend.h"
using namespace llvm;
@@ -31,13 +32,38 @@ public:
virtual bool hasScatteredSymbols() const { return true; }
};
+class DarwinX86_32AsmBackend : public DarwinX86AsmBackend {
+public:
+ DarwinX86_32AsmBackend(const Target &T)
+ : DarwinX86AsmBackend(T) {}
+};
+
+class DarwinX86_64AsmBackend : public DarwinX86AsmBackend {
+public:
+ DarwinX86_64AsmBackend(const Target &T)
+ : DarwinX86AsmBackend(T) {}
+
+ virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
+ // Temporary labels in the string literals sections require symbols. The
+ // issue is that the x86_64 relocation format does not allow symbol +
+ // offset, and so the linker does not have enough information to resolve the
+ // access to the appropriate atom unless an external relocation is used. For
+ // non-cstring sections, we expect the compiler to use a non-temporary label
+ // for anything that could have an addend pointing outside the symbol.
+ //
+ // See <rdar://problem/4765733>.
+ const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section);
+ return SMO.getType() == MCSectionMachO::S_CSTRING_LITERALS;
+ }
+};
+
}
TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
const std::string &TT) {
switch (Triple(TT).getOS()) {
case Triple::Darwin:
- return new DarwinX86AsmBackend(T);
+ return new DarwinX86_32AsmBackend(T);
default:
return new X86AsmBackend(T);
}
@@ -47,7 +73,7 @@ TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
const std::string &TT) {
switch (Triple(TT).getOS()) {
case Triple::Darwin:
- return new DarwinX86AsmBackend(T);
+ return new DarwinX86_64AsmBackend(T);
default:
return new X86AsmBackend(T);
}
OpenPOWER on IntegriCloud