Index: lld/ELF/SyntheticSections.cpp =================================================================== --- lld/ELF/SyntheticSections.cpp +++ lld/ELF/SyntheticSections.cpp @@ -3532,12 +3532,15 @@ for (InputSection *isec : executableSections) { assert(isec->getParent() != nullptr); if (InputSection *d = findExidxSection(isec)) { - memcpy(buf + offset, d->content().data(), d->content().size()); + for (int dataOffset = 0; dataOffset != (int)d->content().size(); + dataOffset += 4) + write32(buf + offset + dataOffset, + read32(d->content().data() + dataOffset)); target->relocateAlloc(*d, buf + d->outSecOff); offset += d->getSize(); } else { // A Linker generated CANTUNWIND section. - memcpy(buf + offset, cantUnwindData, sizeof(cantUnwindData)); + write64(buf + offset, read64(cantUnwindData)); uint64_t s = isec->getVA(); uint64_t p = getVA() + offset; target->relocateNoSym(buf + offset, R_ARM_PREL31, s - p); @@ -3545,7 +3548,7 @@ } } // Write Sentinel. - memcpy(buf + offset, cantUnwindData, sizeof(cantUnwindData)); + write64(buf + offset, read64(cantUnwindData)); uint64_t s = sentinel->getVA(sentinel->getSize()); uint64_t p = getVA() + offset; target->relocateNoSym(buf + offset, R_ARM_PREL31, s - p); Index: lld/ELF/Thunks.cpp =================================================================== --- lld/ELF/Thunks.cpp +++ lld/ELF/Thunks.cpp @@ -530,7 +530,8 @@ uint64_t s = getARMThunkDestVA(destination); uint64_t p = getThunkTargetSym()->getVA(); int64_t offset = s - p - 4; - write32(buf, 0xb000f000); // b.w S + write16(buf + 0, 0xf000); // b.w S + write16(buf + 2, 0xb000); target->relocateNoSym(buf, R_ARM_THM_JUMP24, offset); } Index: lld/test/ELF/arm-data-relocs.s =================================================================== --- /dev/null +++ lld/test/ELF/arm-data-relocs.s @@ -0,0 +1,26 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi -arch=arm %s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi -arch=arm %S/Inputs/abs256.s -o %t256.o +// RUN: ld.lld %t.o %t256.o -o %t +// RUN: llvm-objdump -s %t | FileCheck %s --check-prefixes=CHECK,LE + +// RUN: llvm-mc -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb %s -o %t.be.o +// RUN: llvm-mc -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb %S/Inputs/abs256.s -o %t256.be.o +// RUN: ld.lld --be32 %t.be.o %t256.be.o -o %t.be +// RUN: llvm-objdump -s %t.be | FileCheck %s --check-prefixes=CHECK,BE + +.globl _start +_start: +.section .R_ARM_ABS, "ax","progbits" + .word foo + 0x24 + +// CHECK: Contents of section .R_ARM_ABS: +// LE-NEXT: 200b4 24010000 +// BE-NEXT: 200b4 00000124 + +.section .R_ARM_PREL, "ax","progbits" + .word foo - . + 0x24 + +// CHECK: Contents of section .R_ARM_PREL: +// LE-NEXT: 200b8 6c00feff +// BE-NEXT: 200b8 fffe006c Index: lld/test/ELF/arm-exidx-emit-relocs.s =================================================================== --- lld/test/ELF/arm-exidx-emit-relocs.s +++ lld/test/ELF/arm-exidx-emit-relocs.s @@ -4,6 +4,11 @@ // RUN: llvm-objdump -s --triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s // RUN: llvm-readelf --relocs %t2 | FileCheck -check-prefix=CHECK-RELOCS %s +// RUN: llvm-mc -filetype=obj --arm-add-build-attributes -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t +// RUN: ld.lld --be32 --emit-relocs %t -o %t2 +// RUN: llvm-objdump -s --triple=armv7a-eb-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-EB %s +// RUN: llvm-readelf --relocs %t2 | FileCheck -check-prefix=CHECK-RELOCS %s + /// LLD does not support --emit-relocs for .ARM.exidx sections as the relocations /// from synthetic table entries won't be represented. Given the known use cases /// of --emit-relocs, relocating kernels, and binary analysis, the former doesn't @@ -69,3 +74,8 @@ // CHECK-NEXT: 100f4 20000100 01000000 // CHECK-RELOCS-NOT: Relocation section '.rel.ARM.exidx' + +// CHECK-EB: Contents of section .ARM.exidx: +// CHECK-EB-NEXT: 100d4 00010038 80978408 00010034 80978408 +// CHECK-EB-NEXT: 100e4 00010030 00000001 0001002c 00000001 +// CHECK-EB-NEXT: 100f4 00010028 80978408 00010024 01000000 \ No newline at end of file Index: lld/test/ELF/arm-exidx-relocatable.s =================================================================== --- lld/test/ELF/arm-exidx-relocatable.s +++ lld/test/ELF/arm-exidx-relocatable.s @@ -5,6 +5,12 @@ // RUN: ld.lld -r %t %tcantunwind -o %t4 // RUN: llvm-readobj -S %t4 | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t +// RUN: llvm-mc -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %S/Inputs/arm-exidx-cantunwind.s -o %tcantunwind +// Check that relocatable link maintains SHF_LINK_ORDER for big endian +// RUN: ld.lld --be32 -r %t %tcantunwind -o %t4 +// RUN: llvm-readobj -S %t4 | FileCheck %s + // Each assembler created .ARM.exidx section has the SHF_LINK_ORDER flag set // with the sh_link containing the section index of the executable section // containing the function it describes. To maintain this property in Index: lld/test/ELF/arm-exidx-sentinel-norelocatable.s =================================================================== --- lld/test/ELF/arm-exidx-sentinel-norelocatable.s +++ lld/test/ELF/arm-exidx-sentinel-norelocatable.s @@ -2,6 +2,11 @@ // RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o %t.o // RUN: ld.lld -r %t.o -o %t // RUN: llvm-readobj -S %t | FileCheck %s + +// RUN: llvm-mc %s -triple=armv7-eb-unknown-linux-gnueabi -arch=armeb -mcpu=cortex-a8 -filetype=obj -o %t.o +// RUN: ld.lld --be32 -r %t.o -o %t +// RUN: llvm-readobj -S %t | FileCheck %s + // Check that when doing a relocatable link we don't add a terminating entry // to the .ARM.exidx section .syntax unified Index: lld/test/ELF/arm-header.s =================================================================== --- /dev/null +++ lld/test/ELF/arm-header.s @@ -0,0 +1,25 @@ +# REQUIRES: arm +# RUN: llvm-mc -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t.o +# RUN: ld.lld --be32 %t.o -o %t1 +# RUN: llvm-readobj -h %t1 | FileCheck %s + +# CHECK: Format: elf32-bigarm + +# CHECK: ElfHeader { +# CHECK-NEXT: Ident { +# CHECK-NEXT: Magic: (7F 45 4C 46) +# CHECK-NEXT: Class: 32-bit (0x1) +# CHECK-NEXT: DataEncoding: BigEndian (0x2) +# CHECK-NEXT: FileVersion: 1 +# CHECK-NEXT: OS/ABI: SystemV (0x0) +# CHECK-NEXT: ABIVersion: 0 +# CHECK-NEXT: Unused: (00 00 00 00 00 00 00) +# CHECK-NEXT: } + +# CHECK: Flags [ (0x5000200) +# CHECK-NEXT: 0x200 +# CHECK-NEXT: 0x1000000 +# CHECK-NEXT: 0x4000000 +# CHECK-NEXT: ] + +# CHECK-NOT: 0x800000 \ No newline at end of file Index: lld/test/ELF/arm-mov-relocs.s =================================================================== --- lld/test/ELF/arm-mov-relocs.s +++ lld/test/ELF/arm-mov-relocs.s @@ -6,6 +6,13 @@ // RUN: ld.lld %t3 -o %t4 // RUN: llvm-objdump --no-print-imm-hex -d %t4 --triple=thumbv7a-unknown-linux-gnueabi --no-show-raw-insn | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=armv7a-eb-unknown-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t +// RUN: ld.lld --be32 %t -o %t2 +// RUN: llvm-objdump --no-print-imm-hex -d %t2 --triple=armv7a-unknown-linux-gnueabi --no-show-raw-insn | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-eb-unknown-linux-gnueabi -arch=thumbeb -mcpu=cortex-a8 %s -o %t3 +// RUN: ld.lld --be32 %t3 -o %t4 +// RUN: llvm-objdump --no-print-imm-hex -d %t4 --triple=thumbv7a-unknown-linux-gnueabi --no-show-raw-insn | FileCheck %s + /// Test the following relocation pairs: /// * R_ARM_MOVW_ABS_NC and R_ARM_MOVT_ABS /// * R_ARM_MOVW_PREL_NC and R_ARM_MOVT_PREL Index: lld/test/ELF/arm-plt-reloc.s =================================================================== --- lld/test/ELF/arm-plt-reloc.s +++ lld/test/ELF/arm-plt-reloc.s @@ -306,3 +306,59 @@ // DSORELMIX-NEXT: 0x800202C R_ARM_JUMP_SLOT func1 // DSORELMIX-NEXT: 0x8002030 R_ARM_JUMP_SLOT func2 // DSORELMIX-NEXT: 0x8002034 R_ARM_JUMP_SLOT func3 + +// RUN: llvm-mc -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %p/Inputs/arm-plt-reloc.s -o %t1 +// RUN: llvm-mc -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t2 +// RUN: ld.lld --be32 %t1 %t2 -o %t +// RUN: llvm-objdump --no-print-imm-hex --triple=armv7a-be-none-linux-gnueabi -d --no-show-raw-insn %t | FileCheck %s +// RUN: ld.lld --be32 -shared %t1 %t2 -o %t3 +// RUN: llvm-objdump --no-print-imm-hex --triple=armv7a-be-none-linux-gnueabi -d --no-show-raw-insn %t3 | FileCheck --check-prefix=DSO %s +// RUN: llvm-readobj -S -r %t3 | FileCheck -check-prefix=DSOREL %s + +// RUN: ld.lld --be32 --hash-style=sysv --script %t2.script -shared %t1 %t2 -o %t5 +// RUN: llvm-objdump --no-print-imm-hex --triple=armv7a-none-linux-gnueabi -d --no-show-raw-insn %t5 | FileCheck --check-prefix=CHECKLONG-EB %s +// RUN: llvm-readobj -S -r %t5 | FileCheck --check-prefix=DSORELLONG %s + +// CHECKLONG-EB: Disassembly of section .text: +// CHECKLONG-EB-EMPTY: +// CHECKLONG-EB-NEXT: : +// CHECKLONG-EB-NEXT: 1000: bx lr +// CHECKLONG-EB: : +// CHECKLONG-EB-NEXT: 1004: bx lr +// CHECKLONG-EB: : +// CHECKLONG-EB-NEXT: 1008: bx lr +// CHECKLONG-EB: <_start>: +// CHECKLONG-EB-NEXT: 100c: b 0x2020 +// CHECKLONG-EB-NEXT: 1010: bl 0x2030 +// CHECKLONG-EB-NEXT: 1014: beq 0x2040 +// CHECKLONG-EB-EMPTY: +// CHECKLONG-EB-NEXT: Disassembly of section .plt: +// CHECKLONG-EB-EMPTY: +// CHECKLONG-EB-NEXT: <$a>: +// CHECKLONG-EB-NEXT: 2000: str lr, [sp, #-4]! +// CHECKLONG-EB-NEXT: 2004: ldr lr, [pc, #4] +// CHECKLONG-EB-NEXT: 2008: add lr, pc, lr +// CHECKLONG-EB-NEXT: 200c: ldr pc, [lr, #8]! +// CHECKLONG-EB: <$d>: +// CHECKLONG-EB-NEXT: 2010: 11 10 f0 f0 .word 0x1110f0f0 +// CHECKLONG-EB-NEXT: 2014: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKLONG-EB-NEXT: 2018: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKLONG-EB-NEXT: 201c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKLONG-EB: <$a>: +// CHECKLONG-EB-NEXT: 2020: ldr r12, [pc, #4] +// CHECKLONG-EB-NEXT: 2024: add r12, r12, pc +// CHECKLONG-EB-NEXT: 2028: ldr pc, [r12] +// CHECKLONG-EB: <$d>: +// CHECKLONG-EB-NEXT: 202c: 11 10 f0 e0 .word 0x1110f0e0 +// CHECKLONG-EB: <$a>: +// CHECKLONG-EB-NEXT: 2030: ldr r12, [pc, #4] +// CHECKLONG-EB-NEXT: 2034: add r12, r12, pc +// CHECKLONG-EB-NEXT: 2038: ldr pc, [r12] +// CHECKLONG-EB: <$d>: +// CHECKLONG-EB-NEXT: 203c: 11 10 f0 d4 .word 0x1110f0d4 +// CHECKLONG-EB: <$a>: +// CHECKLONG-EB-NEXT: 2040: ldr r12, [pc, #4] +// CHECKLONG-EB-NEXT: 2044: add r12, r12, pc +// CHECKLONG-EB-NEXT: 2048: ldr pc, [r12] +// CHECKLONG-EB: <$d>: +// CHECKLONG-EB-NEXT: 204c: 11 10 f0 c8 .word 0x1110f0c8 Index: lld/test/ELF/arm-thumb-plt-reloc.s =================================================================== --- lld/test/ELF/arm-thumb-plt-reloc.s +++ lld/test/ELF/arm-thumb-plt-reloc.s @@ -6,7 +6,15 @@ // RUN: ld.lld -shared %t1 %t2 -o %t.so // RUN: llvm-objdump --no-print-imm-hex --triple=thumbv7a-none-linux-gnueabi -d %t.so | FileCheck --check-prefix=DSO %s // RUN: llvm-readobj -S -r %t.so | FileCheck -check-prefix=DSOREL %s -// + +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-eb-none-linux-gnueabi %p/Inputs/arm-plt-reloc.s -o %t1 +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-eb-none-linux-gnueabi %s -o %t2 +// RUN: ld.lld --be32 %t1 %t2 -o %t +// RUN: llvm-objdump --no-print-imm-hex --triple=thumbv7a-eb-none-linux-gnueabi -d %t | FileCheck %s +// RUN: ld.lld --be32 -shared %t1 %t2 -o %t.so +// RUN: llvm-objdump --no-print-imm-hex --triple=thumbv7a-eb-none-linux-gnueabi -d %t.so | FileCheck --check-prefix=DSO %s +// RUN: llvm-readobj -S -r %t.so | FileCheck -check-prefix=DSOREL %s + // Test PLT entry generation .syntax unified .text Index: lld/test/ELF/arm-thunk-arm-thumb-reuse.s =================================================================== --- lld/test/ELF/arm-thunk-arm-thumb-reuse.s +++ lld/test/ELF/arm-thunk-arm-thumb-reuse.s @@ -4,6 +4,10 @@ // RUN: ld.lld --script %t/script %t.o -o %t2 // RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t2 | FileCheck %s +// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %t/test.s -o %t.o +// RUN: ld.lld --be32 --script %t/script %t.o -o %t2 +// RUN: llvm-objdump --no-print-imm-hex --no-show-raw-insn -d %t2 | FileCheck %s + /// Test that we can reuse thunks between Arm and Thumb callers /// using a BL. Expect two thunks, one for far, one for far2. Index: lld/test/ELF/arm-thunk-edgecase.s =================================================================== --- lld/test/ELF/arm-thunk-edgecase.s +++ lld/test/ELF/arm-thunk-edgecase.s @@ -13,6 +13,12 @@ // RUN: llvm-objdump --no-print-imm-hex --triple=armv7a-none-linux-gnueabi -d %tarm_to_thumb.so | FileCheck --check-prefix=ARM-TO-THUMB %s // RUN: llvm-objdump --no-print-imm-hex -d %tthumb_to_arm.so | FileCheck --check-prefix=THUMB-TO-ARM %s +// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t.o +// RUN: ld.lld --be32 -shared -Bsymbolic -script %tarm_to_thumb.script %t.o -o %tarm_to_thumb.so +// RUN: ld.lld --be32 -shared -Bsymbolic -script %tthumb_to_arm.script %t.o -o %tthumb_to_arm.so +// RUN: llvm-objdump --no-print-imm-hex --triple=armv7a-eb-none-linux-gnueabi -d %tarm_to_thumb.so | FileCheck --check-prefix=ARM-TO-THUMB %s +// RUN: llvm-objdump --no-print-imm-hex -d %tthumb_to_arm.so | FileCheck --check-prefix=THUMB-TO-ARM %s + .syntax unified .arm Index: lld/test/ELF/arm-thunk-largesection.s =================================================================== --- lld/test/ELF/arm-thunk-largesection.s +++ lld/test/ELF/arm-thunk-largesection.s @@ -6,6 +6,15 @@ // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --start-address=0x1021ff8 --stop-address=0x1021ffc %t2 | FileCheck --check-prefix=CHECK3 %s // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --start-address=0x2012ff8 --stop-address=0x2021ffc %t2 | FileCheck --check-prefix=CHECK4 %s // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --start-address=0x3021fec --stop-address=0x3021ff6 %t2 | FileCheck --check-prefix=CHECK5 %s + +// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-eb-none-linux-gnueabi -arch=thumbeb -mcpu=cortex-a8 %s -o %t +// RUN: ld.lld --be32 %t -o %t2 +// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --start-address=0x21000 --stop-address=0x21006 %t2 | FileCheck --check-prefix=CHECK1 %s +// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --start-address=0x22004 --stop-address=0x22008 %t2 | FileCheck --check-prefix=CHECK2 %s +// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --start-address=0x1021ff8 --stop-address=0x1021ffc %t2 | FileCheck --check-prefix=CHECK3 %s +// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --start-address=0x2012ff8 --stop-address=0x2021ffc %t2 | FileCheck --check-prefix=CHECK4 %s +// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --start-address=0x3021fec --stop-address=0x3021ff6 %t2 | FileCheck --check-prefix=CHECK5 %s + .syntax unified .balign 0x1000 .thumb Index: lld/test/ELF/arm-thunk-linkerscript-dotexpr.s =================================================================== --- lld/test/ELF/arm-thunk-linkerscript-dotexpr.s +++ lld/test/ELF/arm-thunk-linkerscript-dotexpr.s @@ -7,6 +7,12 @@ // RUN: ld.lld --no-rosegment --script %t.script %t -o %t2 // RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x94 --stop-address=0xbc | FileCheck --check-prefix=CHECK1 %s // RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x20000bc --stop-address=0x20000de | FileCheck --check-prefix=CHECK2 %s + +// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t +// RUN: ld.lld --be32 --no-rosegment --script %t.script %t -o %t2 +// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x94 --stop-address=0xbc | FileCheck --check-prefix=CHECK1 %s +// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x20000bc --stop-address=0x20000de | FileCheck --check-prefix=CHECK2 %s + // Test that range extension thunks can handle location expressions within // a Section Description .syntax unified Index: lld/test/ELF/arm-thunk-linkerscript.s =================================================================== --- lld/test/ELF/arm-thunk-linkerscript.s +++ lld/test/ELF/arm-thunk-linkerscript.s @@ -7,6 +7,11 @@ // RUN: } " > %t.script // RUN: ld.lld --no-rosegment --script %t.script %t -o %t2 // RUN: llvm-objdump --no-print-imm-hex -d %t2 | FileCheck %s + +// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t +// RUN: ld.lld --be32 --no-rosegment --script %t.script %t -o %t2 +// RUN: llvm-objdump --no-print-imm-hex -d %t2 | FileCheck %s + // Simple test that we can support range extension thunks with linker scripts .syntax unified .section .text_low, "ax", %progbits Index: lld/test/ELF/arm-thunk-nosuitable.s =================================================================== --- lld/test/ELF/arm-thunk-nosuitable.s +++ lld/test/ELF/arm-thunk-nosuitable.s @@ -1,6 +1,10 @@ // REQUIRES: arm // RUN: llvm-mc %s --arm-add-build-attributes --triple=armv7a-linux-gnueabihf --filetype=obj -o %t.o // RUN: ld.lld %t.o -o %t +// RUN: llvm-objdump -d --start-address=0x2200b4 --stop-address=0x2200be %t | FileCheck %s + +// RUN: llvm-mc %s --arm-add-build-attributes --triple=armv7a-eb-linux-gnueabihf --filetype=obj -arch=armeb -mcpu=cortex-a8 -o %t.o +// RUN: ld.lld --be32 %t.o -o %t // RUN: llvm-objdump -d --start-address=0x2200b4 --stop-address=0x2200be %t | FileCheck %s /// Create a conditional branch too far away from a precreated thunk Index: lld/test/ELF/arm-thunk-re-add.s =================================================================== --- lld/test/ELF/arm-thunk-re-add.s +++ lld/test/ELF/arm-thunk-re-add.s @@ -122,3 +122,11 @@ // CHECK3-NEXT: 1100058: e5bcf070 ldr pc, [r12, #112]! // CHECK3: <$d>: // CHECK3-NEXT: 110005c: d4 d4 d4 d4 .word 0xd4d4d4d4 + +// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-eb-none-linux-gnueabi -arch=thumbeb -mcpu=cortex-a8 %s -o %t +// RUN: ld.lld --be32 %t --shared -o %t.so +// The output file is large, most of it zeroes. We dissassemble only the +// parts we need to speed up the test and avoid a large output file +// RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1000004 --stop-address=0x100001c | FileCheck --check-prefix=CHECK1 %s +// RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1100008 --stop-address=0x1100022 | FileCheck --check-prefix=CHECK2 %s +// RUN: llvm-objdump --no-print-imm-hex -d %t.so --start-address=0x1100020 --stop-address=0x1100064 --triple=armv7a-eb-linux-gnueabihf | FileCheck --check-prefix=CHECK3 %s \ No newline at end of file Index: lld/test/ELF/arm-thunk-reuse.s =================================================================== --- lld/test/ELF/arm-thunk-reuse.s +++ lld/test/ELF/arm-thunk-reuse.s @@ -4,6 +4,10 @@ # RUN: ld.lld -pie -T %t/lds %t/a.o -o %t/a # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t/a | FileCheck %s +# RUN: llvm-mc -filetype=obj -triple=armv7-eb-a-none-eabi --arm-add-build-attributes -arch=armeb -mcpu=cortex-a8 %t/a.s -o %t/a.o +# RUN: ld.lld --be32 -pie -T %t/lds %t/a.o -o %t/a +# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t/a | FileCheck %s + ## We create a thunk for dest. # CHECK-LABEL: : # CHECK-NEXT: 2010004: b 0x2010008 <__ARMV7PILongThunk_dest> Index: lld/test/ELF/arm-thunk-section-too-large.s =================================================================== --- lld/test/ELF/arm-thunk-section-too-large.s +++ lld/test/ELF/arm-thunk-section-too-large.s @@ -2,6 +2,9 @@ // RUN: llvm-mc %s -triple=armv7a-linux-gnueabihf -arm-add-build-attributes -filetype=obj -o %t.o // RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s +// RUN: llvm-mc %s -triple=armv7a-eb-linux-gnueabihf -arm-add-build-attributes -filetype=obj -arch=armeb -mcpu=cortex-a8 -o %t.o +// RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s + // CHECK: InputSection too large for range extension thunk .syntax unified .thumb Index: lld/test/ELF/arm-thunk-toolargesection.s =================================================================== --- lld/test/ELF/arm-thunk-toolargesection.s +++ lld/test/ELF/arm-thunk-toolargesection.s @@ -1,6 +1,10 @@ // REQUIRES: arm // RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t // RUN: not ld.lld %t -o /dev/null 2>&1 | FileCheck %s + +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-eb-none-linux-gnueabi -arch=thumbeb %s -o %t +// RUN: not ld.lld --be32 %t -o /dev/null 2>&1 | FileCheck %s + .syntax unified .balign 0x1000 .thumb Index: lld/test/ELF/arm-v5-reloc-error.s =================================================================== --- lld/test/ELF/arm-v5-reloc-error.s +++ lld/test/ELF/arm-v5-reloc-error.s @@ -7,6 +7,9 @@ // RUN: } " > %t.script // RUN: not ld.lld --script %t.script %t -o /dev/null 2>&1 | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple=armv7a-eb-linux-gnueabi -arch=armeb -mcpu=cortex-a8 %s -o %t +// RUN: not ld.lld --be32 --script %t.script %t -o /dev/null 2>&1 | FileCheck %s + // CHECK: error: relocation R_ARM_THM_JUMP24 to far not supported for Armv5 or Armv6 targets // Lie about our build attributes. Our triple is armv7a-linux-gnueabi but Index: lld/test/ELF/emulation-arm.s =================================================================== --- lld/test/ELF/emulation-arm.s +++ lld/test/ELF/emulation-arm.s @@ -23,5 +23,36 @@ # ARM-NEXT: Machine: EM_ARM (0x28) # ARM-NEXT: Version: 1 +# RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-eb-none-linux-gnueabi -arch=armeb %s -o %t.o +# RUN: ld.lld --be32 -marmelfb_linux_eabi %t.o -o %t1 +# echo 'OUTPUT_FORMAT(elf32-bigarm)' > %t6arm.script +# ld.lld %tarm -o %t6arm +# RUN: llvm-readobj -h %t1 | FileCheck %s --check-prefix=ARMEB +# RUN: llvm-readobj -h %t1 | FileCheck %s --check-prefix=BE8 + +# ARMEB: ElfHeader { +# ARMEB-NEXT: Ident { +# ARMEB-NEXT: Magic: (7F 45 4C 46) +# ARMEB-NEXT: Class: 32-bit (0x1) +# ARMEB-NEXT: DataEncoding: BigEndian (0x2) +# ARMEB-NEXT: FileVersion: 1 +# ARMEB-NEXT: OS/ABI: SystemV (0x0) +# ARMEB-NEXT: ABIVersion: 0 +# ARMEB-NEXT: Unused: (00 00 00 00 00 00 00) +# ARMEB-NEXT: } +# ARMEB-NEXT: Type: Executable (0x2) +# ARMEB-NEXT: Machine: EM_ARM (0x28) +# ARMEB-NEXT: Version: 1 + +## Ensure that the EF_ARM_BE8 flag is not set for be32 +## This will have to be modified on the be8 is implemented +# ARMEB: Flags [ (0x5000200) +# ARMEB-NEXT: 0x200 +# ARMEB-NEXT: 0x1000000 +# ARMEB-NEXT: 0x4000000 +# ARMEB-NEXT: ] + +# BE8-NOT: 0x800000 + .globl _start _start: