llvm.org GIT mirror llvm / 0599806
Merging r344591: ------------------------------------------------------------------------ r344591 | abeserminji | 2018-10-16 01:27:28 -0700 (Tue, 16 Oct 2018) | 11 lines [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, 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. Differential Revision: https://reviews.llvm.org/D52985 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@347028 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 1 year, 11 months ago
5 changed file(s) with 58 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
164164 return 0;
165165 }
166166
167 /// Check whether a given symbol has been flagged with MICROMIPS flag.
168 virtual bool isMicroMips(const MCSymbol *Sym) const {
169 return false;
170 }
171
167172 /// Handles all target related code padding when starting to write a new
168173 /// basic block to an object file.
169174 ///
523523 if (Asm->isThumbFunc(&SA))
524524 Addend |= 1;
525525
526 // If symbol is labeled as micromips, we set low-bit to ensure
527 // correct offset in .gcc_except_table
528 if (Asm->getBackend().isMicroMips(&SA))
529 Addend |= 1;
530
526531 // Clear the symbol expr pointers to indicate we have folded these
527532 // operands.
528533 A = B = nullptr;
2424 #include "llvm/MC/MCFixupKindInfo.h"
2525 #include "llvm/MC/MCObjectWriter.h"
2626 #include "llvm/MC/MCSubtargetInfo.h"
27 #include "llvm/MC/MCSymbolELF.h"
2728 #include "llvm/MC/MCTargetOptions.h"
2829 #include "llvm/MC/MCValue.h"
2930 #include "llvm/Support/ErrorHandling.h"
567568 }
568569 }
569570
571 bool MipsAsmBackend::isMicroMips(const MCSymbol *Sym) const {
572 if (const auto *ElfSym = dyn_cast(Sym)) {
573 if (ElfSym->getOther() & ELF::STO_MIPS_MICROMIPS)
574 return true;
575 }
576 return false;
577 }
578
570579 MCAsmBackend *llvm::createMipsAsmBackend(const Target &T,
571580 const MCSubtargetInfo &STI,
572581 const MCRegisterInfo &MRI,
2424 struct MCFixupKindInfo;
2525 class MCObjectWriter;
2626 class MCRegisterInfo;
27 class MCSymbolELF;
2728 class Target;
2829
2930 class MipsAsmBackend : public MCAsmBackend {
8990 bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup,
9091 const MCValue &Target) override;
9192
93 bool isMicroMips(const MCSymbol *Sym) const override;
9294 }; // class MipsAsmBackend
9395
9496 } // namespace
0 ; RUN: llc -mtriple=mips-linux-gnu -mcpu=mips32r2 -mattr=+micromips -O3 -filetype=obj < %s | llvm-objdump -s -j .gcc_except_table - | FileCheck %s
1
2 ; CHECK: Contents of section .gcc_except_table:
3 ; CHECK-NEXT: 0000 ff9b1501 0c011100 00110e1f 011f1800
4 ; CHECK-NEXT: 0010 00010000 00000000
5
6 @_ZTIi = external constant i8*
7
8 define dso_local i32 @main() local_unnamed_addr norecurse personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
9 entry:
10 %exception.i = tail call i8* @__cxa_allocate_exception(i32 4) nounwind
11 %0 = bitcast i8* %exception.i to i32*
12 store i32 5, i32* %0, align 16
13 invoke void @__cxa_throw(i8* %exception.i, i8* bitcast (i8** @_ZTIi to i8*), i8* null) noreturn
14 to label %.noexc unwind label %return
15
16 .noexc:
17 unreachable
18
19 return:
20 %1 = landingpad { i8*, i32 }
21 catch i8* null
22 %2 = extractvalue { i8*, i32 } %1, 0
23 %3 = tail call i8* @__cxa_begin_catch(i8* %2) nounwind
24 tail call void @__cxa_end_catch()
25 ret i32 0
26 }
27
28 declare i32 @__gxx_personality_v0(...)
29
30 declare i8* @__cxa_begin_catch(i8*) local_unnamed_addr
31
32 declare void @__cxa_end_catch() local_unnamed_addr
33
34 declare i8* @__cxa_allocate_exception(i32) local_unnamed_addr
35
36 declare void @__cxa_throw(i8*, i8*, i8*) local_unnamed_addr