diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-02-17 23:34:51 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-02-17 23:34:51 +0000 |
commit | df19519800168690eeb5fc92f366820019c62217 (patch) | |
tree | 922badcf72f03c3190eba57a94f282ecf43a5b0b /llvm/lib/Target/TargetLoweringObjectFile.cpp | |
parent | c0a2279099b2c525967e104123f404ff24f26499 (diff) | |
download | bcm5719-llvm-df19519800168690eeb5fc92f366820019c62217.tar.gz bcm5719-llvm-df19519800168690eeb5fc92f366820019c62217.zip |
Add r228939 back with a fix.
The problem in the original patch was not switching back to .text after printing
an eh table.
Original message:
On ELF, put PIC jump tables in a non executable section.
Fixes PR22558.
llvm-svn: 229586
Diffstat (limited to 'llvm/lib/Target/TargetLoweringObjectFile.cpp')
-rw-r--r-- | llvm/lib/Target/TargetLoweringObjectFile.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index c098035a5aa..faa6fbe6075 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -275,6 +275,24 @@ const MCSection *TargetLoweringObjectFile::getSectionForJumpTable( return getSectionForConstant(SectionKind::getReadOnly(), /*C=*/nullptr); } +bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection( + bool UsesLabelDifference, const Function &F) const { + // 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? + if (UsesLabelDifference) + return true; + + // 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. + if (F.isWeakForLinker()) + return true; + + return false; +} + /// getSectionForConstant - Given a mergable constant with the /// specified size and relocation information, return a section that it /// should be placed in. |