summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
diff options
context:
space:
mode:
authorSimon Dardis <simon.dardis@imgtec.com>2017-08-16 12:18:04 +0000
committerSimon Dardis <simon.dardis@imgtec.com>2017-08-16 12:18:04 +0000
commit9c5d64b901cf3b056edf17c9960ae54338a4bd52 (patch)
tree3e5fa2f1c3b44b7f59512e12e5c96a0fa6559311 /llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
parentbba2c83493c8c6293fc9518cbf9f672ae28cedc5 (diff)
downloadbcm5719-llvm-9c5d64b901cf3b056edf17c9960ae54338a4bd52.tar.gz
bcm5719-llvm-9c5d64b901cf3b056edf17c9960ae54338a4bd52.zip
[mips] Handle variables with an explicit section and interactions with .sdata, .sbss
If a variable has an explicit section such as .sdata or .sbss, it is placed in that section and accessed in a gp relative manner. This overrides the global -G setting. Otherwise if a variable has a explicit section attached to it, such as '.rodata' or '.mysection', it is not placed in the small data section. This also overrides the global -G setting. Reviewers: atanasyan, nitesh.jain Differential Revision: https://reviews.llvm.org/D36616 llvm-svn: 311001
Diffstat (limited to 'llvm/lib/Target/Mips/MipsTargetObjectFile.cpp')
-rw-r--r--llvm/lib/Target/Mips/MipsTargetObjectFile.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
index 3bf32e81d57..9db6b7b1bcd 100644
--- a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
@@ -106,6 +106,22 @@ IsGlobalInSmallSectionImpl(const GlobalObject *GO,
if (!GVA)
return false;
+ // If the variable has an explicit section, it is placed in that section but
+ // it's addressing mode may change.
+ if (GVA->hasSection()) {
+ StringRef Section = GVA->getSection();
+
+ // Explicitly placing any variable in the small data section overrides
+ // the global -G value.
+ if (Section == ".sdata" || Section == ".sbss")
+ return true;
+
+ // Otherwise reject accessing it through the gp pointer. There are some
+ // historic cases which GCC doesn't appear to respect any more. These
+ // are .lit4, .lit8 and .srdata. For the moment reject these as well.
+ return false;
+ }
+
// Enforce -mlocal-sdata.
if (!LocalSData && GVA->hasLocalLinkage())
return false;
OpenPOWER on IntegriCloud