# Check that PLT entries are properly generated when link dynamically. # # 1. ARM code generates PLT entries. # RUN: yaml2obj -format=elf -docnum 1 %s > %t-arm.o # RUN: lld -flavor old-gnu -target arm-linux-gnu \ # RUN: --noinhibit-exec %t-arm.o -lfn -L%p/Inputs -o %t # RUN: llvm-objdump -s %t | FileCheck -check-prefix=ARM %s # ARM: Contents of section .rel.plt: # ARM-NEXT: 400134 0c104000 16010000 # GOT addr = 0x40100c ^^ # ARM-NEXT: Contents of section .plt: # ARM-NEXT: 40013c 04e02de5 04e09fe5 0ee08fe0 00f0bee5 # ^ -- PLT0 -- # ARM-NEXT: 40014c bc0e0000 00c68fe2 00ca8ce2 b4febce5 # -- ^ ^ -- PLT_fn -- ^ # ARM-NEXT: Contents of section .text: # ARM-NEXT: 40015c {{[0-9a-f]+}} {{[0-9a-f]+}} f9ffffea # b PLT_fn ^^ # ARM: Contents of section .got.plt: # ARM-NEXT: 401000 00000000 00000000 00000000 3c014000 # PLT0 addr = 0x40013c ^^ # 2. Thumb code generates PLT entries with veneers. # RUN: yaml2obj -format=elf -docnum 2 %s > %t-thm.o # RUN: lld -flavor old-gnu -target arm-linux-gnu \ # RUN: --noinhibit-exec %t-thm.o -lfn -L%p/Inputs -o %t # RUN: llvm-objdump -s %t | FileCheck -check-prefix=THM %s # THM: Contents of section .rel.plt: # THM-NEXT: 400134 0c104000 16010000 # GOT addr = 0x40100c ^^ # THM-NEXT: Contents of section .plt: # THM-NEXT: 40013c 04e02de5 04e09fe5 0ee08fe0 00f0bee5 # ^ -- PLT0 -- # THM-NEXT: 40014c bc0e0000 78470000 00c68fe2 00ca8ce2 # -- ^ veneer ^ ^ -- PLT_fn -- # THM-NEXT: 40015c b0febce5 # -- ^ # THM: Contents of section .text: # THM-NEXT: 400160 {{[0-9a-f]+}} fff7f4bf # b PLT_fn ^^ # 3. Thumb code generates PLT entries without veneers when bl->blx is done. # RUN: yaml2obj -format=elf -docnum 3 %s > %t-thm.o # RUN: lld -flavor old-gnu -target arm-linux-gnu \ # RUN: --noinhibit-exec %t-thm.o -lfn -L%p/Inputs -o %t # RUN: llvm-objdump -s %t | FileCheck -check-prefix=THM-BLX %s # THM-BLX: Contents of section .rel.plt: # THM-BLX-NEXT: 400134 0c104000 16010000 # GOT addr = 0x40100c ^^ # THM-BLX-NEXT: Contents of section .plt: # THM-BLX-NEXT: 40013c 04e02de5 04e09fe5 0ee08fe0 00f0bee5 # ^ -- PLT0 -- # THM-BLX-NEXT: 40014c bc0e0000 00c68fe2 00ca8ce2 b4febce5 # -- ^ ^ -- PLT_fn -- ^ # THM-BLX: Contents of section .text: # THM-BLX-NEXT: 40015c {{[0-9a-f]+}} fff7f6ef # blx PLT_fn ^^ # Generation of mapping symbols. # RUN: yaml2obj -format=elf -docnum 1 %s > %t-arm.o # RUN: lld -flavor old-gnu -target arm-linux-gnu \ # RUN: --noinhibit-exec %t-arm.o -lfn -L%p/Inputs -o %t-arm # RUN: llvm-readobj -symbols %t-arm | FileCheck -check-prefix=ARM-MAPPING %s # ARM-MAPPING: Name: {{[$]?[a]?[.]?}}__PLT0 # ARM-MAPPING: Name: {{[$]?[d]?[.]?}}__PLT0_d # ARM-MAPPING: Name: {{[$]?[a]?[.]?}}__plt_fn # RUN: yaml2obj -format=elf -docnum 2 %s > %t-thm.o # RUN: lld -flavor old-gnu -target arm-linux-gnu \ # RUN: --noinhibit-exec %t-thm.o -lfn -L%p/Inputs -o %t-thm # RUN: llvm-readobj -symbols %t-thm | FileCheck -check-prefix=THM-MAPPING %s # THM-MAPPING: Name: {{[$]?[a]?[.]?}}__PLT0 # THM-MAPPING: Name: {{[$]?[d]?[.]?}}__PLT0_d # THM-MAPPING: Name: {{[$]?[t]?[.]?}}__plt_from_thumb_fn # THM-MAPPING: Name: {{[$]?[a]?[.]?}}__plt_fn # arm.o --- FileHeader: Class: ELFCLASS32 Data: ELFDATA2LSB Type: ET_REL Machine: EM_ARM Flags: [ EF_ARM_EABI_VER5 ] Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x0000000000000004 Content: 00482DE904B08DE2FEFFFFEA0030A0E10300A0E10088BDE8 - Name: .rel.text Type: SHT_REL Link: .symtab AddressAlign: 0x0000000000000004 Info: .text Relocations: - Offset: 0x0000000000000008 Symbol: fn Type: R_ARM_JUMP24 - Name: .data Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000001 Content: '' - Name: .bss Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000001 Symbols: Global: - Name: main Type: STT_FUNC Section: .text - Name: fn # thm.o --- FileHeader: Class: ELFCLASS32 Data: ELFDATA2LSB Type: ET_REL Machine: EM_ARM Flags: [ EF_ARM_EABI_VER5 ] Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x0000000000000004 Content: 80B500AFFFF7FEBF0346184680BD00BF - Name: .rel.text Type: SHT_REL Link: .symtab AddressAlign: 0x0000000000000004 Info: .text Relocations: - Offset: 0x0000000000000004 Symbol: fn Type: R_ARM_THM_JUMP24 - Name: .data Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000001 Content: '' - Name: .bss Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000001 Symbols: Global: - Name: main Type: STT_FUNC Section: .text Value: 0x0000000000000001 - Name: fn # thm-c.o --- FileHeader: Class: ELFCLASS32 Data: ELFDATA2LSB Type: ET_REL Machine: EM_ARM Flags: [ EF_ARM_EABI_VER5 ] Sections: - Name: .text Type: SHT_PROGBITS Flags: [ SHF_ALLOC, SHF_EXECINSTR ] AddressAlign: 0x0000000000000004 Content: 80B500AFFFF7FEFF0346184680BD00BF - Name: .rel.text Type: SHT_REL Link: .symtab AddressAlign: 0x0000000000000004 Info: .text Relocations: - Offset: 0x0000000000000004 Symbol: fn Type: R_ARM_THM_CALL - Name: .data Type: SHT_PROGBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000001 Content: '' - Name: .bss Type: SHT_NOBITS Flags: [ SHF_WRITE, SHF_ALLOC ] AddressAlign: 0x0000000000000001 Symbols: Global: - Name: main Type: STT_FUNC Section: .text Value: 0x0000000000000001 - Name: fn ...