[PATCH] D44963: ELF: Add support for short thunks on ARM.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 28 13:31:15 PDT 2018


pcc added a comment.

In https://reviews.llvm.org/D44963#1050495, @peter.smith wrote:

> Thanks for putting in the effort to doing this, especially updating the tests! This can also apply to AArch64 as well. The only concern that I have right now are whether it is possible to construct an example that oscillates between short and long thunks and would infinite loop if it were not for the iteration count. In general transitioning from a short thunk to a large thunk will increase the distance between sections, however there is one case where adding a thunk, or increasing the distance can shorten a distance.
>
>   OS1 : { *(some sections) }
>   OS2 0x2000000 : { *(some more sections) }
>
>
> If in OS1 the ThunkSection size increases then the gap between the InputSections following it and OS2 will narrow, this might mean that Thunks in OS2 that target OS1 can now be written as short range, which then shrinks the distance between OS1 and the InputSections after the OS2 ThunkSection. I haven't got a test case that provokes this behaviour, neither have I convinced myself that it is impossible. I think that this case could be avoided by never transitioning a thunk from long to short, but I think it will only be worth doing if it is possible to make a failing test case.


It seems to be possible. I was able to come up with this failing test case:

  $ cat test.lds
  SECTIONS {
    .foo : { *(.foo) }
    .bar 0x3000000 : { *(.bar) }
  }
  $ cat test.s
  .section .foo,"ax",%progbits,unique,1
  .zero 0x1000000
  
  .section .foo,"ax",%progbits,unique,2
  foo:
  bl bar
  
  .section .bar,"ax",%progbits,unique,1
  bar:
  bl foo
  .zero 0x1000000
  $ ../ra/bin/llvm-mc -triple armv7-unknown-gnu -filetype=obj -o test.o test.s; ../ra/bin/ld.lld test.o test.lds;objdump -d
  ../ra/bin/ld.lld: warning: lld uses blx instruction, no object with architecture supporting feature detected.
  ../ra/bin/ld.lld: warning: lld uses extended branch encoding, no object with architecture supporting feature detected.
  ../ra/bin/ld.lld: warning: lld may use movt/movw, no object with architecture supporting feature detected.
  ../ra/bin/ld.lld: error: thunk creation not converged

I also think this can be fixed by making sure that we cannot transition from long to short. I will implement that.


https://reviews.llvm.org/D44963





More information about the llvm-commits mailing list