[lld] r281394 - [ELF] Set EF_ARM_EABI_VER5 for ARM
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 13 13:51:33 PDT 2016
Author: ruiu
Date: Tue Sep 13 15:51:32 2016
New Revision: 281394
URL: http://llvm.org/viewvc/llvm-project?rev=281394&view=rev
Log:
[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
Added:
lld/trunk/test/ELF/arm-eabi-version.s
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=281394&r1=281393&r2=281394&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Sep 13 15:51:32 2016
@@ -1262,7 +1262,12 @@ template <class ELFT> void Writer<ELFT>:
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) {
Added: lld/trunk/test/ELF/arm-eabi-version.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-eabi-version.s?rev=281394&view=auto
==============================================================================
--- lld/trunk/test/ELF/arm-eabi-version.s (added)
+++ lld/trunk/test/ELF/arm-eabi-version.s Tue Sep 13 15:51:32 2016
@@ -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: ]
More information about the llvm-commits
mailing list