summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCExpr.cpp
diff options
context:
space:
mode:
authorPetar Jovanovic <petar.jovanovic@mips.com>2019-02-07 22:57:33 +0000
committerPetar Jovanovic <petar.jovanovic@mips.com>2019-02-07 22:57:33 +0000
commit3cfcd75453da6ddcd11ea74dc7a57efc4f1c6cc0 (patch)
tree73e0329aca12b786a5f3bbff48d47e24f1b9c77b /llvm/lib/MC/MCExpr.cpp
parent862e7405e84badb1c1a3529d8132892a34b1c291 (diff)
downloadbcm5719-llvm-3cfcd75453da6ddcd11ea74dc7a57efc4f1c6cc0.tar.gz
bcm5719-llvm-3cfcd75453da6ddcd11ea74dc7a57efc4f1c6cc0.zip
[mips][micromips] Fix how values in .gcc_except_table are calculated
When a landing pad is calculated in a program that is compiled for micromips with -fPIC flag, it will point to an even address. Such an error will cause a segmentation fault, as the instructions in micromips are aligned on odd addresses. This patch sets the last bit of the offset where a landing pad is, to 1, which will effectively be an odd address and point to the instruction exactly. r344591 fixed this issue for -static compilation. Patch by Aleksandar Beserminji. Differential Revision: https://reviews.llvm.org/D57677 llvm-svn: 353480
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r--llvm/lib/MC/MCExpr.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index d8091e41f1a..7ca935f248d 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -558,6 +558,11 @@ static void AttemptToFoldSymbolOffsetDifference(
if (Asm->isThumbFunc(&SA))
Addend |= 1;
+ // If symbol is labeled as micromips, we set low-bit to ensure
+ // correct offset in .gcc_except_table
+ if (Asm->getBackend().isMicroMips(&SA))
+ Addend |= 1;
+
// Clear the symbol expr pointers to indicate we have folded these
// operands.
A = B = nullptr;
OpenPOWER on IntegriCloud