[PATCH] D34689: [LLD][ELF] Pre-create ThunkSections at Target specific intervals
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 17 05:56:22 PDT 2017
peter.smith added a comment.
In https://reviews.llvm.org/D34689#811237, @ikudrin wrote:
> It is possible that a precreated thunk section stays empty in the first pass, but is used in the next pass. In that case, it isn't added into ISR in `ThunkCreator::mergeThunks()`. For example:
>
> $ cat a.s
> .global _start, foo
> .section .text.start,"ax",%progbits
> _start:
> bl _start
> .section .text.dummy1,"ax",%progbits
> .space 0xfffffe
> .section .text.foo,"ax",%progbits
> foo:
> bl _start
> $ llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi a.s -o a.o
> $ ld.lld a.o -o a.out
> $ objdump -d a.out
> a.out: file format elf32-littlearm
>
>
> Disassembly of section .text:
>
> 00011000 <_start>:
> 11000: f7ff effe blx 11000 <_start>
>
> 00011004 <__Thumbv7ABSLongThunk__start>:
> 11004: f241 0c00 movw ip, #4096 ; 0x1000
> 11008: f2c0 0c01 movt ip, #1
> 1100c: 4760 bx ip
> ...
>
> 01011002 <__Thumbv7ABSLongThunk__start>:
> ...
>
> 0101100c <foo>:
> 101100c: f7ff fff9 bl 1011002 <__Thumbv7ABSLongThunk__start>
>
>
> By the way, this sample shows one additional issue: redundant thunks are not removed.
I think you are correct, and I'll need to address the problem of ThunkSections empty on the first pass but not used. I think https://reviews.llvm.org/D34692 would be the better place to do so as this is where multiple places are introduced. Would it be possible to make the comment in https://reviews.llvm.org/D34692, or I can copy it across?
I deliberately didn't try and remove Thunks that are redundant, I'm expecting redundant thunks to only happen when there is a Thunk that has been knocked out of range of all of its callers and I think this will be rare enough to not warrant the extra complexity.
https://reviews.llvm.org/D34689
More information about the llvm-commits
mailing list