This is an archive of the discontinued LLVM Phabricator instance.

[mips][micromips] Fix how values in .gcc_except_table are calculated
ClosedPublic

Authored by abeserminji on Oct 8 2018, 7:57 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

abeserminji created this revision.Oct 8 2018, 7:57 AM
atanasyan added inline comments.Oct 8 2018, 3:42 PM
lib/MC/MCExpr.cpp
10 ↗(On Diff #168649)

Is it really necessary to include MCAsmBackend.h and at the same time add forward declaration of class MCAsmBackend below?

532 ↗(On Diff #168649)

Let's add a comment for these lines (like for lines above).

lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h
21 ↗(On Diff #168649)

Is it really necessary to include MCSymbolELF.h and at the same time add forward declaration of class MCSymbolELF below?

And the test case failed:

test/CodeGen/Mips/micromips-gcc-except-table.ll:4:15: error: CHECK-NEXT: expected string not foundin input
; CHECK-NEXT: 0000 ff9b1501 0c010f00 000f1025 011f1e00
              ^
<stdin>:5:2: note: scanning from here
 0000 ff9b1501 0c011100 00110e1f 011f1800 ................
 ^
abeserminji marked 3 inline comments as done.

Comments addressed.
Test fixed. I have one other patch in progress which affects this test, and forgot to remove it before the submission.

This revision is now accepted and ready to land.Oct 9 2018, 7:12 AM

Removed class forward declaration from MCExpr.cpp. It is not needed.

This revision was automatically updated to reflect the committed changes.

The patch special cased .uleb128 A-B for both direct object file emission and assembling, but changing assembling is not correct.
GNU assembler does not special case .uleb128 A-B to set the least significant bit.

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 10 2023, 11:39 AM