diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-09-13 20:51:32 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-09-13 20:51:32 +0000 |
| commit | 1e2e8eae5d0c5fd4fc12477c1137d13502f7da5a (patch) | |
| tree | 554d06f728c52440ffb1cb39fb4c0622a4ba6ca2 | |
| parent | ea26504c1947756913d348cce575a7bbac7874c3 (diff) | |
| download | bcm5719-llvm-1e2e8eae5d0c5fd4fc12477c1137d13502f7da5a.tar.gz bcm5719-llvm-1e2e8eae5d0c5fd4fc12477c1137d13502f7da5a.zip | |
[ELF] Set EF_ARM_EABI_VER5 for ARM
Without this flag set, an AArch64 Linux kernel won't try to load the executable
(even if a 32 bit arm kernel will run the binary just fine).
Patch by Martin Storsjö!
Differential revision: https://reviews.llvm.org/D24471
llvm-svn: 281394
| -rw-r--r-- | lld/ELF/Writer.cpp | 7 | ||||
| -rw-r--r-- | lld/test/ELF/arm-eabi-version.s | 14 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 1dd73eb1078..5425e0e75c8 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1262,7 +1262,12 @@ template <class ELFT> void Writer<ELFT>::writeHeader() { EHdr->e_shnum = OutputSections.size() + 1; EHdr->e_shstrndx = Out<ELFT>::ShStrTab->SectionIndex; - if (Config->EMachine == EM_MIPS) + if (Config->EMachine == EM_ARM) + // We don't currently use any features incompatible with EF_ARM_EABI_VER5, + // but we don't have any firm guarantees of conformance. Linux AArch64 + // kernels (as of 2016) require an EABI version to be set. + EHdr->e_flags = EF_ARM_EABI_VER5; + else if (Config->EMachine == EM_MIPS) EHdr->e_flags = getMipsEFlags<ELFT>(); if (!Config->Relocatable) { diff --git a/lld/test/ELF/arm-eabi-version.s b/lld/test/ELF/arm-eabi-version.s new file mode 100644 index 00000000000..727b805fddd --- /dev/null +++ b/lld/test/ELF/arm-eabi-version.s @@ -0,0 +1,14 @@ +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o +// RUN: ld.lld -static %t.o -o %tout +// RUN: llvm-readobj -file-headers %tout | FileCheck %s +// REQUIRES: arm + .syntax unified + .text + .globl _start +_start: + bx lr + +// CHECK: Flags [ +// CHECK-NEXT: 0x1000000 +// CHECK-NEXT: 0x4000000 +// CHECK-NEXT: ] |

