summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-12 00:38:17 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-12 00:38:17 +0000
commita5f1d57f65ae601ec181c0f4e36cf0df5e8d79d8 (patch)
tree99cbdd963a1c49327eda3dd44b4ee76b3d797bd9 /lib
parent85f4fdaed4fcc6050499579152c45fde679213d3 (diff)
downloadllvm-a5f1d57f65ae601ec181c0f4e36cf0df5e8d79d8.tar.gz
llvm-a5f1d57f65ae601ec181c0f4e36cf0df5e8d79d8.tar.bz2
llvm-a5f1d57f65ae601ec181c0f4e36cf0df5e8d79d8.tar.xz
MC/Mach-O/x86_64: Add a new hook for checking whether a particular section can
be diced into atoms, and adjust getAtom() to take this into account. - This fixes relocations to symbols in fixed size literal sections, for example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103532 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCAssembler.cpp6
-rw-r--r--lib/Target/X86/X86AsmBackend.cpp20
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 65e3571107..8ec927e415 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -297,6 +297,12 @@ const MCSymbolData *MCAssembler::getAtom(const MCAsmLayout &Layout,
if (!SD->getFragment())
return 0;
+ // Non-linker visible symbols in sections which can't be atomized have no
+ // defining atom.
+ if (!getBackend().isSectionAtomizable(
+ SD->getFragment()->getParent()->getSection()))
+ return 0;
+
// Otherwise, return the atom for the containing fragment.
return SD->getFragment()->getAtom();
}
diff --git a/lib/Target/X86/X86AsmBackend.cpp b/lib/Target/X86/X86AsmBackend.cpp
index b72601ae58..8ee836e1c6 100644
--- a/lib/Target/X86/X86AsmBackend.cpp
+++ b/lib/Target/X86/X86AsmBackend.cpp
@@ -259,6 +259,26 @@ public:
const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section);
return SMO.getType() == MCSectionMachO::S_CSTRING_LITERALS;
}
+
+ virtual bool isSectionAtomizable(const MCSection &Section) const {
+ const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section);
+ // Fixed sized data sections are uniqued, they cannot be diced into atoms.
+ switch (SMO.getType()) {
+ default:
+ return true;
+
+ case MCSectionMachO::S_4BYTE_LITERALS:
+ case MCSectionMachO::S_8BYTE_LITERALS:
+ case MCSectionMachO::S_16BYTE_LITERALS:
+ case MCSectionMachO::S_LITERAL_POINTERS:
+ case MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS:
+ case MCSectionMachO::S_LAZY_SYMBOL_POINTERS:
+ case MCSectionMachO::S_MOD_INIT_FUNC_POINTERS:
+ case MCSectionMachO::S_MOD_TERM_FUNC_POINTERS:
+ case MCSectionMachO::S_INTERPOSING:
+ return false;
+ }
+ }
};
}