[PATCH] D73542: [LLD][ELF][ARM] Do not substitute BL/BLX for non STT_FUNC symbols.

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 5 12:46:17 PST 2020


thakis added a comment.

Here's a reduced repro:

  thakis at thakis:~/src/chrome/src$ cat test.cc
  void foo(int) __attribute__((weak));
  
  int main() {
    if (foo)
      foo(4);
  }
  thakis at thakis:~/src/chrome/src$ third_party/llvm-build/Release+Asserts/bin/clang --target=arm-linux-androideabi16 -fuse-ld=lld test.cc --sysroot=third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot   -fPIC -Bthird_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -mthumb -o a.out.good
  ld.lld: warning: lld uses blx instruction, no object with architecture supporting feature detected
  thakis at thakis:~/src/chrome/src$ ../../llvm-project/out/gn/bin/clang --target=arm-linux-androideabi16 -fuse-ld=lld test.cc --sysroot=third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot   -fPIC -Bthird_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64 -mthumb -o a.out.bad
  ld.lld: warning: lld uses blx instruction, no object with architecture supporting feature detected
  thakis at thakis:~/src/chrome/src$ diff -u <(objdump -d a.out.good) <(objdump -d a.out.bad)
  --- /dev/fd/63	2020-02-05 15:46:00.567207286 -0500
  +++ /dev/fd/62	2020-02-05 15:46:00.567207286 -0500
  @@ -1,5 +1,5 @@
   
  -a.out.good:     file format elf32-littlearm
  +a.out.bad:     file format elf32-littlearm
   
   
   Disassembly of section .text:
  @@ -59,7 +59,7 @@
       1422:	d004      	beq.n	142e <main+0x1e>
       1424:	e7ff      	b.n	1426 <main+0x16>
       1426:	2004      	movs	r0, #4
  -    1428:	f000 e82a 	blx	1480 <main+0x70>
  +    1428:	f000 f82a 	bl	1480 <main+0x70>
       142c:	e7ff      	b.n	142e <main+0x1e>
       142e:	9801      	ldr	r0, [sp, #4]
       1430:	b002      	add	sp, #8


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73542/new/

https://reviews.llvm.org/D73542





More information about the llvm-commits mailing list