diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-02-12 17:46:49 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-02-12 17:46:49 +0000 |
| commit | 203c5b9f39cbd9bc4ab3538537b36614af3274a8 (patch) | |
| tree | 7e779fd92118a64ff6db03ab2236e75148c95b91 /llvm/lib/CodeGen/AsmPrinter | |
| parent | e732052f1661e9760827c18093169cf137c89850 (diff) | |
| download | bcm5719-llvm-203c5b9f39cbd9bc4ab3538537b36614af3274a8.tar.gz bcm5719-llvm-203c5b9f39cbd9bc4ab3538537b36614af3274a8.zip | |
On ELF, put PIC jump tables in a non executable section.
Fixes PR22558.
llvm-svn: 228939
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index aacc486aa14..5a01e0e9b6f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1178,23 +1178,14 @@ void AsmPrinter::EmitJumpTableInfo() { // the appropriate section. const Function *F = MF->getFunction(); const TargetLoweringObjectFile &TLOF = getObjFileLowering(); - bool JTInDiffSection = false; - if (// In PIC mode, we need to emit the jump table to the same section as the - // function body itself, otherwise the label differences won't make sense. - // FIXME: Need a better predicate for this: what about custom entries? - MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 || - // We should also do if the section name is NULL or function is declared - // in discardable section - // FIXME: this isn't the right predicate, should be based on the MCSection - // for the function. - F->isWeakForLinker()) { - OutStreamer.SwitchSection(TLOF.SectionForGlobal(F, *Mang, TM)); - } else { + bool JTInDiffSection = !TLOF.shouldPutJumpTableInFunctionSection( + MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32, + *F); + if (JTInDiffSection) { // Otherwise, drop it in the readonly section. const MCSection *ReadOnlySection = TLOF.getSectionForJumpTable(*F, *Mang, TM); OutStreamer.SwitchSection(ReadOnlySection); - JTInDiffSection = true; } EmitAlignment(Log2_32( |

