llvm.org GIT mirror llvm / eaad8e9
Merging r353480: ------------------------------------------------------------------------ r353480 | petarj | 2019-02-07 23:57:33 +0100 (Thu, 07 Feb 2019) | 15 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 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 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_80@353827 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 1 year, 9 months ago
3 changed file(s) with 26 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
558558 if (Asm->isThumbFunc(&SA))
559559 Addend |= 1;
560560
561 // If symbol is labeled as micromips, we set low-bit to ensure
562 // correct offset in .gcc_except_table
563 if (Asm->getBackend().isMicroMips(&SA))
564 Addend |= 1;
565
561566 // Clear the symbol expr pointers to indicate we have folded these
562567 // operands.
563568 A = B = nullptr;
1212 ; CHECK-NEXT: 1e: fb fd 00 00 sw $ra, 0($sp)
1313 ; CHECK-NEXT: 22: 41 a1 00 01 lui $1, 1
1414 ; CHECK-NEXT: 26: 40 60 00 02 bal 8
15 ; CHECK-NEXT: 2a: 30 21 04 68 addiu $1, $1, 1128
15 ; CHECK-NEXT: 2a: 30 21 04 69 addiu $1, $1, 1129
1616 ; CHECK-NEXT: 2e: 00 3f 09 50 addu $1, $ra, $1
1717 ; CHECK-NEXT: 32: ff fd 00 00 lw $ra, 0($sp)
1818 ; CHECK-NEXT: 36: 00 01 0f 3c jr $1
2626 ; CHECK-NEXT: 56: fb fd 00 00 sw $ra, 0($sp)
2727 ; CHECK-NEXT: 5a: 41 a1 00 01 lui $1, 1
2828 ; CHECK-NEXT: 5e: 40 60 00 02 bal 8
29 ; CHECK-NEXT: 62: 30 21 04 5c addiu $1, $1, 1116
29 ; CHECK-NEXT: 62: 30 21 04 5d addiu $1, $1, 1117
3030 ; CHECK-NEXT: 66: 00 3f 09 50 addu $1, $ra, $1
3131 ; CHECK-NEXT: 6a: ff fd 00 00 lw $ra, 0($sp)
3232 ; CHECK-NEXT: 6e: 00 01 0f 3c jr $1
3838 ; CHECK-NEXT: 86: fb fd 00 00 sw $ra, 0($sp)
3939 ; CHECK-NEXT: 8a: 41 a1 00 01 lui $1, 1
4040 ; CHECK-NEXT: 8e: 40 60 00 02 bal 8
41 ; CHECK-NEXT: 92: 30 21 04 2c addiu $1, $1, 1068
41 ; CHECK-NEXT: 92: 30 21 04 2d addiu $1, $1, 1069
4242 ; CHECK-NEXT: 96: 00 3f 09 50 addu $1, $ra, $1
4343 ; CHECK-NEXT: 9a: ff fd 00 00 lw $ra, 0($sp)
4444 ; CHECK-NEXT: 9e: 00 01 0f 3c jr $1
5050 ; CHECK-NEXT: 10476: fb fd 00 00 sw $ra, 0($sp)
5151 ; CHECK-NEXT: 1047a: 41 a1 00 01 lui $1, 1
5252 ; CHECK-NEXT: 1047e: 40 60 00 02 bal 8
53 ; CHECK-NEXT: 10482: 30 21 04 00 addiu $1, $1, 1024
53 ; CHECK-NEXT: 10482: 30 21 04 01 addiu $1, $1, 1025
5454 ; CHECK-NEXT: 10486: 00 3f 09 50 addu $1, $ra, $1
5555 ; CHECK-NEXT: 1048a: ff fd 00 00 lw $ra, 0($sp)
5656 ; CHECK-NEXT: 1048e: 00 01 0f 3c jr $1
None ; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips -O3 -filetype=obj -o - %s | llvm-readelf -r | FileCheck %s
0 ; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips -relocation-model=static -O3 -filetype=obj -o - %s | \
1 ; RUN: llvm-readelf -r | FileCheck %s --check-prefix=CHECK-READELF
2 ; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips -relocation-model=pic -O3 -filetype=obj -o - %s | \
3 ; RUN: llvm-readelf -r | FileCheck %s --check-prefix=CHECK-READELF
4 ; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips -relocation-model=static -O3 -filetype=obj -o - %s | \
5 ; RUN: llvm-objdump -s -j .gcc_except_table - | FileCheck %s --check-prefix=CHECK-EXCEPT-TABLE-STATIC
6 ; RUN: llc -mtriple mips-unknown-linux-gnu -mattr=+micromips -relocation-model=pic -O3 -filetype=obj -o - %s | \
7 ; RUN: llvm-objdump -s -j .gcc_except_table - | FileCheck %s --check-prefix=CHECK-EXCEPT-TABLE-PIC
18
2 ; CHECK: .rel.eh_frame
3 ; CHECK: DW.ref.__gxx_personality_v0
4 ; CHECK-NEXT: .text
5 ; CHECK-NEXT: .gcc_except_table
9 ; CHECK-READELF: .rel.eh_frame
10 ; CHECK-READELF: DW.ref.__gxx_personality_v0
11 ; CHECK-READELF-NEXT: .text
12 ; CHECK-READELF-NEXT: .gcc_except_table
13
14 ; CHECK-EXCEPT-TABLE-STATIC: 0000 ff9b1501 0c011500 00150e23 01231e00 ...........#.#..
15 ; CHECK-EXCEPT-TABLE-STATIC: 0010 00010000 00000000
16 ; CHECK-EXCEPT-TABLE-PIC: 0000 ff9b1501 0c012d00 002d133f 013f2a00 ......-..-.?.?*.
17 ; CHECK-EXCEPT-TABLE-PIC: 0010 00010000 00000000 ........
618
719 @_ZTIi = external constant i8*
820