llvm.org GIT mirror llvm / 7515784
Merging r344516: ------------------------------------------------------------------------ r344516 | abeserminji | 2018-10-15 07:39:12 -0700 (Mon, 15 Oct 2018) | 12 lines [mips][micromips] Fix overlaping FDEs error When compiling static executable for micromips, CFI symbols are incorrectly labeled as MICROMIPS, which cause ".eh_frame_hdr refers to overlapping FDEs." error. This patch does not label CFI symbols as MICROMIPS, and FDEs do not overlap anymore. This patch also exposes another bug, which is fixed here: https://reviews.llvm.org/D52985 Differential Revision: https://reviews.llvm.org/D52987 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@347023 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 1 year, 11 months ago
3 changed file(s) with 62 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1414 #include "llvm/MC/MCAssembler.h"
1515 #include "llvm/MC/MCCodeEmitter.h"
1616 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCDwarf.h"
1718 #include "llvm/MC/MCInst.h"
1819 #include "llvm/MC/MCObjectWriter.h"
1920 #include "llvm/MC/MCSymbolELF.h"
5051 }
5152
5253 createPendingLabelRelocs();
54 }
55
56 void MipsELFStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
57 Frame.Begin = getContext().createTempSymbol();
58 MCELFStreamer::EmitLabel(Frame.Begin);
59 }
60
61 MCSymbol *MipsELFStreamer::EmitCFILabel() {
62 MCSymbol *Label = getContext().createTempSymbol("cfi", true);
63 MCELFStreamer::EmitLabel(Label);
64 return Label;
65 }
66
67 void MipsELFStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
68 Frame.End = getContext().createTempSymbol();
69 MCELFStreamer::EmitLabel(Frame.End);
5370 }
5471
5572 void MipsELFStreamer::createPendingLabelRelocs() {
2525 class MCCodeEmitter;
2626 class MCContext;
2727 class MCSubtargetInfo;
28 struct MCDwarfFrameInfo;
2829
2930 class MipsELFStreamer : public MCELFStreamer {
3031 SmallVector, 8> MipsOptionRecords;
5960 void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override;
6061 void EmitIntValue(uint64_t Value, unsigned Size) override;
6162
63 // Overriding these functions allows us to avoid recording of these labels
64 // in EmitLabel and later marking them as microMIPS.
65 void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
66 void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
67 MCSymbol *EmitCFILabel() override;
68
6269 /// Emits all the option records stored up until the point it's called.
6370 void EmitMipsOptionRecords();
6471
0 ; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips -O3 -filetype=obj -o - %s | llvm-readelf -r | FileCheck %s
1
2 ; CHECK: .rel.eh_frame
3 ; CHECK: DW.ref.__gxx_personality_v0
4 ; CHECK-NEXT: .text
5 ; CHECK-NEXT: .gcc_except_table
6
7 @_ZTIi = external constant i8*
8
9 define dso_local i32 @main() local_unnamed_addr personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
10 entry:
11 %exception.i = tail call i8* @__cxa_allocate_exception(i32 4) nounwind
12 %0 = bitcast i8* %exception.i to i32*
13 store i32 5, i32* %0, align 16
14 invoke void @__cxa_throw(i8* %exception.i, i8* bitcast (i8** @_ZTIi to i8*), i8* null) noreturn
15 to label %.noexc unwind label %return
16
17 .noexc:
18 unreachable
19
20 return:
21 %1 = landingpad { i8*, i32 }
22 catch i8* null
23 %2 = extractvalue { i8*, i32 } %1, 0
24 %3 = tail call i8* @__cxa_begin_catch(i8* %2) nounwind
25 tail call void @__cxa_end_catch()
26 ret i32 0
27 }
28
29 declare i32 @__gxx_personality_v0(...)
30
31 declare i8* @__cxa_begin_catch(i8*) local_unnamed_addr
32
33 declare void @__cxa_end_catch() local_unnamed_addr
34
35 declare i8* @__cxa_allocate_exception(i32) local_unnamed_addr
36
37 declare void @__cxa_throw(i8*, i8*, i8*) local_unnamed_addr