diff options
author | Denis Protivensky <dprotivensky@accesssoftek.com> | 2015-04-22 07:51:26 +0000 |
---|---|---|
committer | Denis Protivensky <dprotivensky@accesssoftek.com> | 2015-04-22 07:51:26 +0000 |
commit | 4b0abddeeadbece3a97713806604db192fbbf53e (patch) | |
tree | c89a85a0adc9669b28aac1146efccaa72b295507 | |
parent | f6c8938edda1ef6037dd4d9a5bf77cea54b09651 (diff) | |
download | bcm5719-llvm-4b0abddeeadbece3a97713806604db192fbbf53e.tar.gz bcm5719-llvm-4b0abddeeadbece3a97713806604db192fbbf53e.zip |
[ARM] Implement veneers for dynamic executable linking
llvm-svn: 235486
-rw-r--r-- | lld/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp | 10 | ||||
-rw-r--r-- | lld/test/elf/ARM/rel-arm-jump24-veneer-b.test | 49 | ||||
-rw-r--r-- | lld/test/elf/ARM/rel-arm-jump24-veneer-bl.test | 46 | ||||
-rw-r--r-- | lld/test/elf/ARM/rel-thm-jump24-veneer.test | 44 |
4 files changed, 111 insertions, 38 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp b/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp index 531d4e6a8aa..6badc5e0779 100644 --- a/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp +++ b/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp @@ -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. diff --git a/lld/test/elf/ARM/rel-arm-jump24-veneer-b.test b/lld/test/elf/ARM/rel-arm-jump24-veneer-b.test index 4caeac083b8..d14fd0dadbb 100644 --- a/lld/test/elf/ARM/rel-arm-jump24-veneer-b.test +++ b/lld/test/elf/ARM/rel-arm-jump24-veneer-b.test @@ -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 --- diff --git a/lld/test/elf/ARM/rel-arm-jump24-veneer-bl.test b/lld/test/elf/ARM/rel-arm-jump24-veneer-bl.test index cd386dc5b1a..3c9e1c28ebb 100644 --- a/lld/test/elf/ARM/rel-arm-jump24-veneer-bl.test +++ b/lld/test/elf/ARM/rel-arm-jump24-veneer-bl.test @@ -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 --- diff --git a/lld/test/elf/ARM/rel-thm-jump24-veneer.test b/lld/test/elf/ARM/rel-thm-jump24-veneer.test index fffce44ca47..ecad0ab31c2 100644 --- a/lld/test/elf/ARM/rel-thm-jump24-veneer.test +++ b/lld/test/elf/ARM/rel-thm-jump24-veneer.test @@ -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 -# B-VENEER: Contents of section .text: -# B-VENEER: 400074 {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} 00f000b8 +# 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 {{[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 --- |