aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2014-03-14 12:45:22 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2014-03-14 12:45:22 +0000
commitf445399870e5d3e70be72db0e5ac6aa4d581d8ca (patch)
treeff7e49b9e56b335276fe4d16a2441b1a654d55a8 /llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp
parent3554912129073eb282877ac553f0ea2da0adfd9f (diff)
downloadllvm-f445399870e5d3e70be72db0e5ac6aa4d581d8ca.zip
llvm-f445399870e5d3e70be72db0e5ac6aa4d581d8ca.tar.gz
llvm-f445399870e5d3e70be72db0e5ac6aa4d581d8ca.tar.bz2
[ppc64] Avoid copy relocs in named rodata sections
Commit r181723 introduced code to avoid placing initialized variables needing relocations into the .rodata section, which avoid copy relocs that do not work as expected on ppc64 function references. The same treatment is also needed for *named* .rodata.XXX sections. This patch changes PPC64LinuxTargetObjectFile::SelectSectionForGlobal to modify "Kind" *before* calling the default SelectSectionForGlobal routine, instead of first calling the default routine and then just checking for the (main) .rodata section afterwards. llvm-svn: 203921
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp b/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp
index 2e8605c..2903cc1 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetObjectFile.cpp
@@ -25,13 +25,6 @@ Initialize(MCContext &Ctx, const TargetMachine &TM) {
const MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal(
const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
const TargetMachine &TM) const {
-
- const MCSection *DefaultSection =
- TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind, Mang, TM);
-
- if (DefaultSection != ReadOnlySection)
- return DefaultSection;
-
// Here override ReadOnlySection to DataRelROSection for PPC64 SVR4 ABI
// when we have a constant that contains global relocations. This is
// necessary because of this ABI's handling of pointers to functions in
@@ -46,14 +39,17 @@ const MCSection *PPC64LinuxTargetObjectFile::SelectSectionForGlobal(
// linker, so we must use DataRelROSection instead of ReadOnlySection.
// For more information, see the description of ELIMINATE_COPY_RELOCS in
// GNU ld.
- const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
+ if (Kind.isReadOnly()) {
+ const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
- if (GVar && GVar->isConstant() &&
- (GVar->getInitializer()->getRelocationInfo() ==
- Constant::GlobalRelocations))
- return DataRelROSection;
+ if (GVar && GVar->isConstant() &&
+ (GVar->getInitializer()->getRelocationInfo() ==
+ Constant::GlobalRelocations))
+ Kind = SectionKind::getReadOnlyWithRel();
+ }
- return DefaultSection;
+ return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind,
+ Mang, TM);
}
const MCExpr *PPC64LinuxTargetObjectFile::