[lld] r235486 - [ARM] Implement veneers for dynamic executable linking

Denis Protivensky dprotivensky at accesssoftek.com
Wed Apr 22 00:51:26 PDT 2015


Author: denis-protivensky
Date: Wed Apr 22 02:51:26 2015
New Revision: 235486

URL: http://llvm.org/viewvc/llvm-project?rev=235486&view=rev
Log:
[ARM] Implement veneers for dynamic executable linking

Modified:
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
    lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-b.test
    lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-bl.test
    lld/trunk/test/elf/ARM/rel-thm-jump24-veneer.test

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp?rev=235486&r1=235485&r2=235486&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp Wed Apr 22 02:51:26 2015
@@ -873,13 +873,19 @@ public:
   /// \brief Get the veneer for ARM B/BL instructions.
   const VeneerAtom *getVeneer_ARM_B_BL(const DefinedAtom *da,
                                        StringRef secName) {
-    llvm_unreachable("Handle ARM veneer");
+    if (_ctx.getOutputELFType() == llvm::ELF::ET_EXEC) {
+      return getVeneer_ARM_B_BL_Abs(da, secName);
+    }
+    llvm_unreachable("Handle ARM veneer for DSOs");
   }
 
   /// \brief Get the veneer for Thumb B/BL instructions.
   const VeneerAtom *getVeneer_THM_B_BL(const DefinedAtom *da,
                                        StringRef secName) {
-    llvm_unreachable("Handle Thumb veneer");
+    if (_ctx.getOutputELFType() == llvm::ELF::ET_EXEC) {
+      return getVeneer_THM_B_BL_Abs(da, secName);
+    }
+    llvm_unreachable("Handle Thumb veneer for DSOs");
   }
 
   /// \brief Create a GOT entry for R_ARM_TLS_TPOFF32 reloc.

Modified: lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-b.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-b.test?rev=235486&r1=235485&r2=235486&view=diff
==============================================================================
--- lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-b.test (original)
+++ lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-b.test Wed Apr 22 02:51:26 2015
@@ -4,28 +4,51 @@
 # RUN: yaml2obj -format=elf -docnum 2 %s > %t-thm.o
 # RUN: lld -flavor gnu -target arm -m armelf_linux_eabi -Bstatic \
 # RUN: --noinhibit-exec %t-arm.o %t-thm.o -o %t
+# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=STATIC %s
 
-# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=B-VENEER %s
-# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=B-ADDR %s
-
-# B-VENEER: Contents of section .text:
-# B-VENEER: 400074 010000ea
+# STATIC: Contents of section .text:
+# STATIC: 400074 010000ea
 # Call from main:
-#       offset = 0x4  ^^
+#     offset = 0x4  ^^
 #               call site   offset  PC(arm)   ___Z1fv_from_arm addr
 #               0x400074  +  0x4  +  0x8   =   0x400080
 #
 # Code of the veneer:
-# B-VENEER:                 {{[0-9a-f]+}} {{[0-9a-f]+}} 04f01fe5
-# B-VENEER: 400084 79004000
-# call addr = 0x400079 ^^
+# STATIC:                 {{[0-9a-f]+}} {{[0-9a-f]+}} 04f01fe5
+# STATIC: 400084 79004000
+#                   ^^ call addr = 0x400079
 #               call addr   _Z1fv addr  Thumb mode
 #               0x400079  =  0x400078  |  0x1
 #
-# B-ADDR: SYMBOL TABLE:
-# B-ADDR: 00400080 l     F .text  {{[0-9a-f]+}} ___Z1fv_from_arm
-# B-ADDR: 00400074 g     F .text  {{[0-9a-f]+}} main
-# B-ADDR: 00400078 g     F .text  {{[0-9a-f]+}} _Z1fv
+# STATIC: SYMBOL TABLE:
+# STATIC: 00400080 l     F .text  {{[0-9a-f]+}} ___Z1fv_from_arm
+# STATIC: 00400074 g     F .text  {{[0-9a-f]+}} main
+# STATIC: 00400078 g     F .text  {{[0-9a-f]+}} _Z1fv
+
+# RUN: yaml2obj -format=elf -docnum 1 %s > %t-arm.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t-thm.o
+# RUN: lld -flavor gnu -target arm -m armelf_linux_eabi \
+# RUN: --noinhibit-exec %t-arm.o %t-thm.o -o %t
+# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=EXEC-DYN %s
+
+# EXEC-DYN: Contents of section .text:
+# EXEC-DYN: 400114 010000ea
+# Call from main:
+#     offset = 0x4  ^^
+#               call site   offset  PC(arm)   ___Z1fv_from_arm addr
+#               0x400114  +  0x4  +  0x8   =   0x400120
+#
+# Code of the veneer:
+# EXEC-DYN:                 {{[0-9a-f]+}} {{[0-9a-f]+}} 04f01fe5
+# EXEC-DYN: 400124 19014000
+# call addr = 0x400119 ^^
+#               call addr   _Z1fv addr  Thumb mode
+#               0x400119  =  0x400118  |  0x1
+#
+# EXEC-DYN: SYMBOL TABLE:
+# EXEC-DYN: 00400120 l     F .text  {{[0-9a-f]+}} ___Z1fv_from_arm
+# EXEC-DYN: 00400114 g     F .text  {{[0-9a-f]+}} main
+# EXEC-DYN: 00400118 g     F .text  {{[0-9a-f]+}} _Z1fv
 
 # arm.o
 ---

Modified: lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-bl.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-bl.test?rev=235486&r1=235485&r2=235486&view=diff
==============================================================================
--- lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-bl.test (original)
+++ lld/trunk/test/elf/ARM/rel-arm-jump24-veneer-bl.test Wed Apr 22 02:51:26 2015
@@ -4,27 +4,49 @@
 # RUN: yaml2obj -format=elf -docnum 2 %s > %t-thm.o
 # RUN: lld -flavor gnu -target arm -m armelf_linux_eabi -Bstatic \
 # RUN: --noinhibit-exec %t-arm.o %t-thm.o -o %t
+# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=STATIC %s
 
-# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=BL-VENEER %s
-# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=BL-ADDR %s
-
-# BL-VENEER: Contents of section .text:
-# BL-VENEER: 400084 0400000b
+# STATIC: Contents of section .text:
+# STATIC: 400084 0400000b
 # Call from main:
-#      offset = 0x10  ^^
+#    offset = 0x10  ^^
 #               call site   offset   PC(arm)   ___Z1fv_from_arm addr
 #               0x400084  +  0x10  +  0x8   =   0x40009c
 #
 # Code of the veneer:
-# BL-VENEER: 400094 {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} 95004000
-#                                           call addr = 0x400095 ^^
+# STATIC: 400094 {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} 95004000
+#                                        call addr = 0x400095 ^^
 #               call addr   _Z1fv addr  Thumb mode
 #               0x400095  =  0x400094  |  0x1
 #
-# BL-ADDR: SYMBOL TABLE:
-# BL-ADDR: 0040009c l     F .text  {{[0-9a-f]+}} ___Z1fv_from_arm
-# BL-ADDR: 00400074 g     F .text  {{[0-9a-f]+}} main
-# BL-ADDR: 00400094 g     F .text  {{[0-9a-f]+}} _Z1fv
+# STATIC: SYMBOL TABLE:
+# STATIC: 0040009c l     F .text  {{[0-9a-f]+}} ___Z1fv_from_arm
+# STATIC: 00400074 g     F .text  {{[0-9a-f]+}} main
+# STATIC: 00400094 g     F .text  {{[0-9a-f]+}} _Z1fv
+
+# RUN: yaml2obj -format=elf -docnum 1 %s > %t-arm.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t-thm.o
+# RUN: lld -flavor gnu -target arm -m armelf_linux_eabi \
+# RUN: --noinhibit-exec %t-arm.o %t-thm.o -o %t
+# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=EXEC-DYN %s
+
+# EXEC-DYN: Contents of section .text:
+# EXEC-DYN: 400124 0400000b
+# Call from main:
+#      offset = 0x10  ^^
+#               call site   offset   PC(arm)   ___Z1fv_from_arm addr
+#               0x400124  +  0x10  +  0x8   =   0x40013c
+#
+# Code of the veneer:
+# EXEC-DYN: 400134 {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} 35014000
+#                                          call addr = 0x400135 ^^
+#               call addr   _Z1fv addr  Thumb mode
+#               0x400135  =  0x400134  |  0x1
+#
+# EXEC-DYN: SYMBOL TABLE:
+# EXEC-DYN: 0040013c l     F .text  {{[0-9a-f]+}} ___Z1fv_from_arm
+# EXEC-DYN: 00400114 g     F .text  {{[0-9a-f]+}} main
+# EXEC-DYN: 00400134 g     F .text  {{[0-9a-f]+}} _Z1fv
 
 # arm.o
 ---

Modified: lld/trunk/test/elf/ARM/rel-thm-jump24-veneer.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/ARM/rel-thm-jump24-veneer.test?rev=235486&r1=235485&r2=235486&view=diff
==============================================================================
--- lld/trunk/test/elf/ARM/rel-thm-jump24-veneer.test (original)
+++ lld/trunk/test/elf/ARM/rel-thm-jump24-veneer.test Wed Apr 22 02:51:26 2015
@@ -4,27 +4,49 @@
 # RUN: yaml2obj -format=elf -docnum 2 %s > %t-thm.o
 # RUN: lld -flavor gnu -target arm -m armelf_linux_eabi -Bstatic \
 # RUN: --noinhibit-exec %t-arm.o %t-thm.o -o %t
+# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=STATIC %s
 
-# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=B-VENEER %s
-# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=B-ADDR %s
+# STATIC: Contents of section .text:
+# STATIC: 400074 {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} 00f000b8
+# Call from main:
+#                                               offset = 0x0  ^^
+#               call site   offset  PC(thm)   ___Z1fv_from_thumb addr
+#               0x400080  +  0x0  +  0x4   =   0x400084
+#
+# Code of the veneer:
+# STATIC: 400084 78470000 f9ffffea
+#             offset = -0x1C ^^
+#               call site    offset   PC(arm)      _Z1fv
+#               0x400088  + (-0x1C) +  0x8   =   0x400074
+#
+# STATIC: SYMBOL TABLE:
+# STATIC: 00400084 l     F .text  {{[0-9a-f]+}} ___Z1fv_from_thumb
+# STATIC: 00400074 g     F .text  {{[0-9a-f]+}} _Z1fv
+# STATIC: 00400080 g     F .text  {{[0-9a-f]+}} main
+
+# RUN: yaml2obj -format=elf -docnum 1 %s > %t-arm.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t-thm.o
+# RUN: lld -flavor gnu -target arm -m armelf_linux_eabi \
+# RUN: --noinhibit-exec %t-arm.o %t-thm.o -o %t
+# RUN: llvm-objdump -s -t %t | FileCheck -check-prefix=EXEC-DYN %s
 
-# B-VENEER: Contents of section .text:
-# B-VENEER: 400074 {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} 00f000b8
+# EXEC-DYN: Contents of section .text:
+# EXEC-DYN: 400114 {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} 00f000b8
 # Call from main:
 #                                                 offset = 0x0  ^^
 #               call site   offset  PC(thm)   ___Z1fv_from_thumb addr
-#               0x400080  +  0x0  +  0x4   =   0x400084
+#               0x400120  +  0x0  +  0x4   =   0x400124
 #
 # Code of the veneer:
-# B-VENEER: 400084 78470000 f9ffffea
+# EXEC-DYN: 400124 78470000 f9ffffea
 #               offset = -0x1C ^^
 #               call site    offset   PC(arm)      _Z1fv
-#               0x400088  + (-0x1C) +  0x8   =   0x400074
+#               0x400128  + (-0x1C) +  0x8   =   0x400114
 #
-# B-ADDR: SYMBOL TABLE:
-# B-ADDR: 00400084 l     F .text  {{[0-9a-f]+}} ___Z1fv_from_thumb
-# B-ADDR: 00400074 g     F .text  {{[0-9a-f]+}} _Z1fv
-# B-ADDR: 00400080 g     F .text  {{[0-9a-f]+}} main
+# EXEC-DYN: SYMBOL TABLE:
+# EXEC-DYN: 00400124 l     F .text  {{[0-9a-f]+}} ___Z1fv_from_thumb
+# EXEC-DYN: 00400114 g     F .text  {{[0-9a-f]+}} _Z1fv
+# EXEC-DYN: 00400120 g     F .text  {{[0-9a-f]+}} main
 
 # arm.o
 ---





More information about the llvm-commits mailing list