-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld][ARM] Fix assertion when mixing ARM and Thumb objects (#101985)
Previously, we selected the Thumb2 PLT sequences if any input object is marked as not supporting the ARM ISA, which then causes assertion failures when calls from ARM code in other objects are seen. I think the intention here was to only use Thumb PLTs when the target does not have the ARM ISA available, signalled by no objects being marked as having it available. To do that we need to track which ISAs we have seen as we parse the build attributes, and defer the decision about PLTs until all input objects have been parsed. This bug was triggered by real code in picolibc, which have some versions of string.h functions built with Thumb2-only build attributes, so that they are compatible with v7-A, v7-R and v7-M. Fixes #99008.
- Loading branch information
Showing
4 changed files
with
62 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# REQUIRES: arm | ||
|
||
# RUN: rm -rf %t && split-file %s %t | ||
# RUN: llvm-mc -filetype=obj -arm-add-build-attributes -triple=armv7a-none-linux-gnueabi %t/a.s -o %t1.o | ||
# RUN: llvm-mc -filetype=obj -arm-add-build-attributes -triple=armv7a-none-linux-gnueabi %t/b.s -o %t2.o | ||
# RUN: ld.lld -shared %t1.o %t2.o -o %t.so | ||
# RUN: llvm-objdump -d %t.so | FileCheck %s | ||
|
||
## Check that, when the input is a mixture of objects which can and cannot use | ||
## the ARM ISA, we use the default ARM PLT sequences. | ||
|
||
# CHECK: <.plt>: | ||
# CHECK-NEXT: e52de004 str lr, [sp, #-0x4]! | ||
# CHECK-NEXT: e28fe600 add lr, pc, #0, #12 | ||
# CHECK-NEXT: e28eea20 add lr, lr, #32, #20 | ||
# CHECK-NEXT: e5bef084 ldr pc, [lr, #0x84]! | ||
# CHECK-NEXT: d4 d4 d4 d4 .word 0xd4d4d4d4 | ||
# CHECK-NEXT: d4 d4 d4 d4 .word 0xd4d4d4d4 | ||
# CHECK-NEXT: d4 d4 d4 d4 .word 0xd4d4d4d4 | ||
# CHECK-NEXT: d4 d4 d4 d4 .word 0xd4d4d4d4 | ||
# CHECK-NEXT: e28fc600 add r12, pc, #0, #12 | ||
# CHECK-NEXT: e28cca20 add r12, r12, #32, #20 | ||
# CHECK-NEXT: e5bcf06c ldr pc, [r12, #0x6c]! | ||
# CHECK-NEXT: d4 d4 d4 d4 .word 0xd4d4d4d4 | ||
|
||
#--- a.s | ||
.globl foo | ||
.type foo, %function | ||
.globl bar | ||
.type bar, %function | ||
|
||
.thumb | ||
foo: | ||
bl bar | ||
bx lr | ||
|
||
#--- b.s | ||
.eabi_attribute Tag_ARM_ISA_use, 0 | ||
|
||
.arm | ||
.globl bar | ||
.type bar, %function | ||
bar: | ||
bx lr |