aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/TargetMachine.cpp
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2024-01-29 21:00:16 -0700
committerGitHub <noreply@github.com>2024-01-29 21:00:16 -0700
commit198652a0ff2553c4ba906be10c22af57d20d0bd3 (patch)
treec64a243a0d3f600c52d4ab62e526a4515d4ffe60 /llvm/lib/Target/TargetMachine.cpp
parent7f6d4455231d458a6925ca5c957bb2814c196ea2 (diff)
downloadllvm-198652a0ff2553c4ba906be10c22af57d20d0bd3.zip
llvm-198652a0ff2553c4ba906be10c22af57d20d0bd3.tar.gz
llvm-198652a0ff2553c4ba906be10c22af57d20d0bd3.tar.bz2
[X86] Treat __start_*/__stop_* symbols as large (#79909)
Followup to #79884. The linker adds __start_foo/__stop_foo symbols pointing to the beginning/end of the foo section. These can be far away from text, so treat them as large symbols under the medium/large code models. Performance to access these is almost certainly not important.
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r--llvm/lib/Target/TargetMachine.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index 178d199..4258a76 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -85,7 +85,11 @@ bool TargetMachine::isLargeGlobalValue(const GlobalValue *GVal) const {
getCodeModel() == CodeModel::Large) {
if (!GV->getValueType()->isSized())
return true;
- if (GV->isDeclaration() && GV->getName() == "__ehdr_start")
+ // Linker defined start/stop symbols can point to arbitrary points in the
+ // binary, so treat them as large.
+ if (GV->isDeclaration() && (GV->getName() == "__ehdr_start" ||
+ GV->getName().starts_with("__start_") ||
+ GV->getName().starts_with("__stop_")))
return true;
const DataLayout &DL = GV->getParent()->getDataLayout();
uint64_t Size = DL.getTypeSizeInBits(GV->getValueType()) / 8;