mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-01 13:20:25 +00:00
[ELF] Accept first SHT_ARM_ATTRIBUTES section
The eglibc library, as used by Ubuntu 14.04 requires the presence of an SHT_ARM_ATTRIBUTES section in for the purposes of checking hard/soft float compatibility when dlopen() is used. Unfortunately when the section is not present dlopen() fails with a generic could not find file message. This change makes lld keep the first .ARM.attributes section that it encounters and propagates it to the output. This is not a complete SHT_ARM_ATTRIBUTES implementation, that would involve reading the contents of the section and joining each individual attribute. It should suffice for a homogenous build all libraries and executables on the same system with a compatible set of command line options. Differential revision: https://reviews.llvm.org/D27718 llvm-svn: 289642
This commit is contained in:
parent
3abd1d3e12
commit
532bc984f5
@ -14,6 +14,7 @@
|
||||
#include "LinkerScript.h"
|
||||
#include "SymbolTable.h"
|
||||
#include "Symbols.h"
|
||||
#include "SyntheticSections.h"
|
||||
#include "lld/Support/Memory.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Bitcode/BitcodeReader.h"
|
||||
@ -336,8 +337,14 @@ elf::ObjectFile<ELFT>::createInputSection(const Elf_Shdr &Sec,
|
||||
|
||||
switch (Sec.sh_type) {
|
||||
case SHT_ARM_ATTRIBUTES:
|
||||
// FIXME: ARM meta-data section. At present attributes are ignored,
|
||||
// they can be used to reason about object compatibility.
|
||||
// FIXME: ARM meta-data section. Retain the first attribute section
|
||||
// we see. The eglibc ARM dynamic loaders require the presence of an
|
||||
// attribute section for dlopen to work.
|
||||
// In a full implementation we would merge all attribute sections.
|
||||
if (In<ELFT>::ARMAttributes == nullptr) {
|
||||
In<ELFT>::ARMAttributes = make<InputSection<ELFT>>(this, &Sec, Name);
|
||||
return In<ELFT>::ARMAttributes;
|
||||
}
|
||||
return &InputSection<ELFT>::Discarded;
|
||||
case SHT_RELA:
|
||||
case SHT_REL: {
|
||||
|
@ -667,6 +667,7 @@ template <class ELFT> MergeInputSection<ELFT> *createCommentSection();
|
||||
|
||||
// Linker generated sections which can be used as inputs.
|
||||
template <class ELFT> struct In {
|
||||
static InputSection<ELFT> *ARMAttributes;
|
||||
static BuildIdSection<ELFT> *BuildId;
|
||||
static InputSection<ELFT> *Common;
|
||||
static DynamicSection<ELFT> *Dynamic;
|
||||
@ -695,6 +696,7 @@ template <class ELFT> struct In {
|
||||
static VersionNeedSection<ELFT> *VerNeed;
|
||||
};
|
||||
|
||||
template <class ELFT> InputSection<ELFT> *In<ELFT>::ARMAttributes;
|
||||
template <class ELFT> BuildIdSection<ELFT> *In<ELFT>::BuildId;
|
||||
template <class ELFT> InputSection<ELFT> *In<ELFT>::Common;
|
||||
template <class ELFT> DynamicSection<ELFT> *In<ELFT>::Dynamic;
|
||||
|
@ -1,20 +1,4 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
|
||||
// RUN: ld.lld %t.o -o %t
|
||||
// RUN: llvm-readobj -s %t | FileCheck %s
|
||||
// RUN: ld.lld %t.o -shared -o %t2
|
||||
// RUN: llvm-readobj -s %t2 | FileCheck %s
|
||||
// RUN: ld.lld %t.o -r -o %t3
|
||||
// RUN: llvm-readobj -s %t3 | FileCheck %s
|
||||
|
||||
// The .ARM.attributes section should be removed from executables and
|
||||
// shared objects.
|
||||
|
||||
// At present we remove it from the -r object output as well which isn't ideal.
|
||||
// Unfortunately combining per-object attributes cannot be safely done by just
|
||||
// concatentation of input sections.
|
||||
|
||||
// CHECK-NOT: Name: .ARM.attributes
|
||||
// REQUIRES: arm
|
||||
// Input that generates an object with a populated SHT_ARM_ATTRIBUTES section
|
||||
.text
|
||||
.syntax unified
|
||||
.eabi_attribute 67, "2.09" @ Tag_conformance
|
||||
@ -38,8 +22,8 @@
|
||||
.eabi_attribute 26, 2 @ Tag_ABI_enum_size
|
||||
.eabi_attribute 14, 0 @ Tag_ABI_PCS_R9_use
|
||||
.eabi_attribute 68, 1 @ Tag_Virtualization_use
|
||||
.globl _start
|
||||
.globl func
|
||||
.p2align 2
|
||||
.type _start,%function
|
||||
_start:
|
||||
.type func,%function
|
||||
func:
|
||||
bx lr
|
183
lld/test/ELF/arm-attributes.s
Normal file
183
lld/test/ELF/arm-attributes.s
Normal file
@ -0,0 +1,183 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-attributes1.s -o %t1.o
|
||||
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t2.o
|
||||
|
||||
// RUN: ld.lld %t1.o %t2.o -o %t
|
||||
// RUN: llvm-readobj -arm-attributes %t | FileCheck %s
|
||||
// RUN: ld.lld %t1.o %t2.o -shared -o %t2
|
||||
// RUN: llvm-readobj -arm-attributes %t2 | FileCheck %s
|
||||
// RUN: ld.lld %t1.o %t2.o -r -o %t3
|
||||
// RUN: llvm-readobj -arm-attributes %t3 | FileCheck %s
|
||||
// REQUIRES: arm
|
||||
|
||||
// Check that we retain only 1 SHT_ARM_ATTRIBUTES section. At present we do not
|
||||
// try and merge or use the contents of SHT_ARM_ATTRIBUTES sections. We just
|
||||
// pass the first one through.
|
||||
.text
|
||||
.syntax unified
|
||||
.eabi_attribute 67, "2.09" @ Tag_conformance
|
||||
.cpu cortex-a8
|
||||
.eabi_attribute 6, 10 @ Tag_CPU_arch
|
||||
.eabi_attribute 7, 65 @ Tag_CPU_arch_profile
|
||||
.eabi_attribute 8, 1 @ Tag_ARM_ISA_use
|
||||
.eabi_attribute 9, 2 @ Tag_THUMB_ISA_use
|
||||
.fpu neon
|
||||
.eabi_attribute 15, 1 @ Tag_ABI_PCS_RW_data
|
||||
.eabi_attribute 16, 1 @ Tag_ABI_PCS_RO_data
|
||||
.eabi_attribute 17, 2 @ Tag_ABI_PCS_GOT_use
|
||||
.eabi_attribute 20, 1 @ Tag_ABI_FP_denormal
|
||||
.eabi_attribute 21, 1 @ Tag_ABI_FP_exceptions
|
||||
.eabi_attribute 23, 3 @ Tag_ABI_FP_number_model
|
||||
.eabi_attribute 34, 1 @ Tag_CPU_unaligned_access
|
||||
.eabi_attribute 24, 1 @ Tag_ABI_align_needed
|
||||
.eabi_attribute 25, 1 @ Tag_ABI_align_preserved
|
||||
.eabi_attribute 38, 1 @ Tag_ABI_FP_16bit_format
|
||||
.eabi_attribute 18, 4 @ Tag_ABI_PCS_wchar_t
|
||||
.eabi_attribute 26, 2 @ Tag_ABI_enum_size
|
||||
.eabi_attribute 14, 0 @ Tag_ABI_PCS_R9_use
|
||||
.eabi_attribute 68, 1 @ Tag_Virtualization_use
|
||||
.globl _start
|
||||
.p2align 2
|
||||
.type _start,%function
|
||||
_start:
|
||||
.globl func
|
||||
bl func
|
||||
bx lr
|
||||
|
||||
// CHECK: BuildAttributes {
|
||||
// CHECK-NEXT: FormatVersion: 0x41
|
||||
// CHECK-NEXT: Section 1 {
|
||||
// CHECK-NEXT: SectionLength: 72
|
||||
// CHECK-NEXT: Vendor: aeabi
|
||||
// CHECK-NEXT: Tag: Tag_File (0x1)
|
||||
// CHECK-NEXT: Size: 62
|
||||
// CHECK-NEXT: FileAttributes {
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 67
|
||||
// CHECK-NEXT: TagName: conformance
|
||||
// CHECK-NEXT: Value: 2.09
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 5
|
||||
// CHECK-NEXT: TagName: CPU_name
|
||||
// CHECK-NEXT: Value: cortex-a8
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 6
|
||||
// CHECK-NEXT: Value: 10
|
||||
// CHECK-NEXT: TagName: CPU_arch
|
||||
// CHECK-NEXT: Description: ARM v7
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 7
|
||||
// CHECK-NEXT: Value: 65
|
||||
// CHECK-NEXT: TagName: CPU_arch_profile
|
||||
// CHECK-NEXT: Description: Application
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 8
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: ARM_ISA_use
|
||||
// CHECK-NEXT: Description: Permitted
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 9
|
||||
// CHECK-NEXT: Value: 2
|
||||
// CHECK-NEXT: TagName: THUMB_ISA_use
|
||||
// CHECK-NEXT: Description: Thumb-2
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 10
|
||||
// CHECK-NEXT: Value: 3
|
||||
// CHECK-NEXT: TagName: FP_arch
|
||||
// CHECK-NEXT: Description: VFPv3
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 12
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: Advanced_SIMD_arch
|
||||
// CHECK-NEXT: Description: NEONv1
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 14
|
||||
// CHECK-NEXT: Value: 0
|
||||
// CHECK-NEXT: TagName: ABI_PCS_R9_use
|
||||
// CHECK-NEXT: Description: v6
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 15
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: ABI_PCS_RW_data
|
||||
// CHECK-NEXT: Description: PC-relative
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 16
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: ABI_PCS_RO_data
|
||||
// CHECK-NEXT: Description: PC-relative
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 17
|
||||
// CHECK-NEXT: Value: 2
|
||||
// CHECK-NEXT: TagName: ABI_PCS_GOT_use
|
||||
// CHECK-NEXT: Description: GOT-Indirect
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 18
|
||||
// CHECK-NEXT: Value: 4
|
||||
// CHECK-NEXT: TagName: ABI_PCS_wchar_t
|
||||
// CHECK-NEXT: Description: 4-byte
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 20
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: ABI_FP_denormal
|
||||
// CHECK-NEXT: Description: IEEE-754
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 21
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: ABI_FP_exceptions
|
||||
// CHECK-NEXT: Description: IEEE-754
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 23
|
||||
// CHECK-NEXT: Value: 3
|
||||
// CHECK-NEXT: TagName: ABI_FP_number_model
|
||||
// CHECK-NEXT: Description: IEEE-754
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 24
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: ABI_align_needed
|
||||
// CHECK-NEXT: Description: 8-byte alignment
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 25
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: ABI_align_preserved
|
||||
// CHECK-NEXT: Description: 8-byte data alignment
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 26
|
||||
// CHECK-NEXT: Value: 2
|
||||
// CHECK-NEXT: TagName: ABI_enum_size
|
||||
// CHECK-NEXT: Description: Int32
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 34
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: CPU_unaligned_access
|
||||
// CHECK-NEXT: Description: v6-style
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 38
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: ABI_FP_16bit_format
|
||||
// CHECK-NEXT: Description: IEEE-754
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: Attribute {
|
||||
// CHECK-NEXT: Tag: 68
|
||||
// CHECK-NEXT: Value: 1
|
||||
// CHECK-NEXT: TagName: Virtualization_use
|
||||
// CHECK-NEXT: Description: TrustZone
|
||||
// CHECK-NEXT: }
|
Loading…
Reference in New Issue
Block a user