X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felfnn-aarch64.c;h=b6f083e430bb51e6930d4663f60362079101511c;hb=957b1d8f2ff6c3fdf8f0fc00ab5e2ac9f82254a9;hp=083f90b57de38b6e1c58c991c851978ec1751717;hpb=9fca35fc3486283562a7fcd9eb0ff845b0152d98;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 083f90b57d..b6f083e430 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -1,5 +1,5 @@ /* AArch64-specific support for NN-bit ELF. - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2021 Free Software Foundation, Inc. Contributed by ARM Ltd. This file is part of BFD, the Binary File Descriptor library. @@ -139,12 +139,12 @@ #include "bfd.h" #include "libiberty.h" #include "libbfd.h" -#include "bfd_stdint.h" #include "elf-bfd.h" #include "bfdlink.h" #include "objalloc.h" #include "elf/aarch64.h" #include "elfxx-aarch64.h" +#include "cpu-aarch64.h" #define ARCH_SIZE NN @@ -268,6 +268,12 @@ #define PLT_ENTRY_SIZE (32) #define PLT_SMALL_ENTRY_SIZE (16) #define PLT_TLSDESC_ENTRY_SIZE (32) +/* PLT sizes with BTI insn. */ +#define PLT_BTI_SMALL_ENTRY_SIZE (24) +/* PLT sizes with PAC insn. */ +#define PLT_PAC_SMALL_ENTRY_SIZE (24) +/* PLT sizes with BTI and PAC insn. */ +#define PLT_BTI_PAC_SMALL_ENTRY_SIZE (24) /* Encoding of the nop instruction. */ #define INSN_NOP 0xd503201f @@ -298,9 +304,26 @@ static const bfd_byte elfNN_aarch64_small_plt0_entry[PLT_ENTRY_SIZE] = 0x1f, 0x20, 0x03, 0xd5, /* nop */ }; +static const bfd_byte elfNN_aarch64_small_plt0_bti_entry[PLT_ENTRY_SIZE] = +{ + 0x5f, 0x24, 0x03, 0xd5, /* bti c. */ + 0xf0, 0x7b, 0xbf, 0xa9, /* stp x16, x30, [sp, #-16]! */ + 0x10, 0x00, 0x00, 0x90, /* adrp x16, (GOT+16) */ +#if ARCH_SIZE == 64 + 0x11, 0x0A, 0x40, 0xf9, /* ldr x17, [x16, #PLT_GOT+0x10] */ + 0x10, 0x42, 0x00, 0x91, /* add x16, x16,#PLT_GOT+0x10 */ +#else + 0x11, 0x0A, 0x40, 0xb9, /* ldr w17, [x16, #PLT_GOT+0x8] */ + 0x10, 0x22, 0x00, 0x11, /* add w16, w16,#PLT_GOT+0x8 */ +#endif + 0x20, 0x02, 0x1f, 0xd6, /* br x17 */ + 0x1f, 0x20, 0x03, 0xd5, /* nop */ + 0x1f, 0x20, 0x03, 0xd5, /* nop */ +}; + /* Per function entry in a procedure linkage table looks like this if the distance between the PLTGOT and the PLT is < 4GB use - these PLT entries. */ + these PLT entries. Use BTI versions of the PLTs when enabled. */ static const bfd_byte elfNN_aarch64_small_plt_entry[PLT_SMALL_ENTRY_SIZE] = { 0x10, 0x00, 0x00, 0x90, /* adrp x16, PLTGOT + n * 8 */ @@ -314,6 +337,54 @@ static const bfd_byte elfNN_aarch64_small_plt_entry[PLT_SMALL_ENTRY_SIZE] = 0x20, 0x02, 0x1f, 0xd6, /* br x17. */ }; +static const bfd_byte +elfNN_aarch64_small_plt_bti_entry[PLT_BTI_SMALL_ENTRY_SIZE] = +{ + 0x5f, 0x24, 0x03, 0xd5, /* bti c. */ + 0x10, 0x00, 0x00, 0x90, /* adrp x16, PLTGOT + n * 8 */ +#if ARCH_SIZE == 64 + 0x11, 0x02, 0x40, 0xf9, /* ldr x17, [x16, PLTGOT + n * 8] */ + 0x10, 0x02, 0x00, 0x91, /* add x16, x16, :lo12:PLTGOT + n * 8 */ +#else + 0x11, 0x02, 0x40, 0xb9, /* ldr w17, [x16, PLTGOT + n * 4] */ + 0x10, 0x02, 0x00, 0x11, /* add w16, w16, :lo12:PLTGOT + n * 4 */ +#endif + 0x20, 0x02, 0x1f, 0xd6, /* br x17. */ + 0x1f, 0x20, 0x03, 0xd5, /* nop */ +}; + +static const bfd_byte +elfNN_aarch64_small_plt_pac_entry[PLT_PAC_SMALL_ENTRY_SIZE] = +{ + 0x10, 0x00, 0x00, 0x90, /* adrp x16, PLTGOT + n * 8 */ +#if ARCH_SIZE == 64 + 0x11, 0x02, 0x40, 0xf9, /* ldr x17, [x16, PLTGOT + n * 8] */ + 0x10, 0x02, 0x00, 0x91, /* add x16, x16, :lo12:PLTGOT + n * 8 */ +#else + 0x11, 0x02, 0x40, 0xb9, /* ldr w17, [x16, PLTGOT + n * 4] */ + 0x10, 0x02, 0x00, 0x11, /* add w16, w16, :lo12:PLTGOT + n * 4 */ +#endif + 0x9f, 0x21, 0x03, 0xd5, /* autia1716 */ + 0x20, 0x02, 0x1f, 0xd6, /* br x17. */ + 0x1f, 0x20, 0x03, 0xd5, /* nop */ +}; + +static const bfd_byte +elfNN_aarch64_small_plt_bti_pac_entry[PLT_BTI_PAC_SMALL_ENTRY_SIZE] = +{ + 0x5f, 0x24, 0x03, 0xd5, /* bti c. */ + 0x10, 0x00, 0x00, 0x90, /* adrp x16, PLTGOT + n * 8 */ +#if ARCH_SIZE == 64 + 0x11, 0x02, 0x40, 0xf9, /* ldr x17, [x16, PLTGOT + n * 8] */ + 0x10, 0x02, 0x00, 0x91, /* add x16, x16, :lo12:PLTGOT + n * 8 */ +#else + 0x11, 0x02, 0x40, 0xb9, /* ldr w17, [x16, PLTGOT + n * 4] */ + 0x10, 0x02, 0x00, 0x11, /* add w16, w16, :lo12:PLTGOT + n * 4 */ +#endif + 0x9f, 0x21, 0x03, 0xd5, /* autia1716 */ + 0x20, 0x02, 0x1f, 0xd6, /* br x17. */ +}; + static const bfd_byte elfNN_aarch64_tlsdesc_small_plt_entry[PLT_TLSDESC_ENTRY_SIZE] = { @@ -332,6 +403,24 @@ elfNN_aarch64_tlsdesc_small_plt_entry[PLT_TLSDESC_ENTRY_SIZE] = 0x1f, 0x20, 0x03, 0xd5, /* nop */ }; +static const bfd_byte +elfNN_aarch64_tlsdesc_small_plt_bti_entry[PLT_TLSDESC_ENTRY_SIZE] = +{ + 0x5f, 0x24, 0x03, 0xd5, /* bti c. */ + 0xe2, 0x0f, 0xbf, 0xa9, /* stp x2, x3, [sp, #-16]! */ + 0x02, 0x00, 0x00, 0x90, /* adrp x2, 0 */ + 0x03, 0x00, 0x00, 0x90, /* adrp x3, 0 */ +#if ARCH_SIZE == 64 + 0x42, 0x00, 0x40, 0xf9, /* ldr x2, [x2, #0] */ + 0x63, 0x00, 0x00, 0x91, /* add x3, x3, 0 */ +#else + 0x42, 0x00, 0x40, 0xb9, /* ldr w2, [x2, #0] */ + 0x63, 0x00, 0x00, 0x11, /* add w3, w3, 0 */ +#endif + 0x40, 0x00, 0x1f, 0xd6, /* br x2 */ + 0x1f, 0x20, 0x03, 0xd5, /* nop */ +}; + #define elf_info_to_howto elfNN_aarch64_info_to_howto #define elf_info_to_howto_rel elfNN_aarch64_info_to_howto @@ -355,118 +444,118 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 0, /* rightshift */ 3, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_AARCH64_NULL", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (R_AARCH64_NONE, /* type */ 0, /* rightshift */ 3, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_AARCH64_NONE", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* .xword: (S+A) */ HOWTO64 (AARCH64_R (ABS64), /* type */ 0, /* rightshift */ 4, /* size (4 = long long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (ABS64), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ ALL_ONES, /* src_mask */ ALL_ONES, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* .word: (S+A) */ HOWTO (AARCH64_R (ABS32), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (ABS32), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* .half: (S+A) */ HOWTO (AARCH64_R (ABS16), /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (ABS16), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* .xword: (S+A-P) */ HOWTO64 (AARCH64_R (PREL64), /* type */ 0, /* rightshift */ 4, /* size (4 = long long) */ 64, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (PREL64), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ ALL_ONES, /* src_mask */ ALL_ONES, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* .word: (S+A-P) */ HOWTO (AARCH64_R (PREL32), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (PREL32), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* .half: (S+A-P) */ HOWTO (AARCH64_R (PREL16), /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (PREL16), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* Group relocations to create a 16, 32, 48 or 64 bit unsigned data or abs address inline. */ @@ -476,105 +565,105 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_UABS_G0), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVK: ((S+A) >> 0) & 0xffff [no overflow check] */ HOWTO (AARCH64_R (MOVW_UABS_G0_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_UABS_G0_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVZ: ((S+A) >> 16) & 0xffff */ HOWTO (AARCH64_R (MOVW_UABS_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_UABS_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVK: ((S+A) >> 16) & 0xffff [no overflow check] */ HOWTO64 (AARCH64_R (MOVW_UABS_G1_NC), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_UABS_G1_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVZ: ((S+A) >> 32) & 0xffff */ HOWTO64 (AARCH64_R (MOVW_UABS_G2), /* type */ 32, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_UABS_G2), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVK: ((S+A) >> 32) & 0xffff [no overflow check] */ HOWTO64 (AARCH64_R (MOVW_UABS_G2_NC), /* type */ 32, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_UABS_G2_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVZ: ((S+A) >> 48) & 0xffff */ HOWTO64 (AARCH64_R (MOVW_UABS_G3), /* type */ 48, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_UABS_G3), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Group relocations to create high part of a 16, 32, 48 or 64 bit signed data or abs address inline. Will change instruction @@ -585,153 +674,153 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 17, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_SABS_G0), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOV[ZN]: ((S+A) >> 16) & 0xffff */ HOWTO64 (AARCH64_R (MOVW_SABS_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 17, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_SABS_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOV[ZN]: ((S+A) >> 32) & 0xffff */ HOWTO64 (AARCH64_R (MOVW_SABS_G2), /* type */ 32, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 17, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_SABS_G2), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Group relocations to create a 16, 32, 48 or 64 bit PC relative address inline. */ /* MOV[NZ]: ((S+A-P) >> 0) & 0xffff */ - HOWTO64 (AARCH64_R (MOVW_PREL_G0), /* type */ + HOWTO (AARCH64_R (MOVW_PREL_G0), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 17, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_PREL_G0), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* MOVK: ((S+A-P) >> 0) & 0xffff [no overflow check] */ - HOWTO64 (AARCH64_R (MOVW_PREL_G0_NC), /* type */ + HOWTO (AARCH64_R (MOVW_PREL_G0_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_PREL_G0_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* MOV[NZ]: ((S+A-P) >> 16) & 0xffff */ - HOWTO64 (AARCH64_R (MOVW_PREL_G1), /* type */ + HOWTO (AARCH64_R (MOVW_PREL_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 17, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_PREL_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* MOVK: ((S+A-P) >> 16) & 0xffff [no overflow check] */ HOWTO64 (AARCH64_R (MOVW_PREL_G1_NC), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_PREL_G1_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* MOV[NZ]: ((S+A-P) >> 32) & 0xffff */ HOWTO64 (AARCH64_R (MOVW_PREL_G2), /* type */ 32, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 17, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_PREL_G2), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* MOVK: ((S+A-P) >> 32) & 0xffff [no overflow check] */ HOWTO64 (AARCH64_R (MOVW_PREL_G2_NC), /* type */ 32, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_PREL_G2_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* MOV[NZ]: ((S+A-P) >> 48) & 0xffff */ HOWTO64 (AARCH64_R (MOVW_PREL_G3), /* type */ 48, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_PREL_G3), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* Relocations to generate 19, 21 and 33 bit PC-relative load/store addresses: PG(x) is (x & ~0xfff). */ @@ -741,90 +830,90 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 19, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LD_PREL_LO19), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x7ffff, /* src_mask */ 0x7ffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* ADR: (S+A-P) & 0x1fffff */ HOWTO (AARCH64_R (ADR_PREL_LO21), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (ADR_PREL_LO21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* ADRP: ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */ HOWTO (AARCH64_R (ADR_PREL_PG_HI21), /* type */ 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (ADR_PREL_PG_HI21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* ADRP: ((PG(S+A)-PG(P)) >> 12) & 0x1fffff [no overflow check] */ HOWTO64 (AARCH64_R (ADR_PREL_PG_HI21_NC), /* type */ 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (ADR_PREL_PG_HI21_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* ADD: (S+A) & 0xfff [no overflow check] */ HOWTO (AARCH64_R (ADD_ABS_LO12_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (ADD_ABS_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffc00, /* src_mask */ 0x3ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST8: (S+A) & 0xfff */ HOWTO (AARCH64_R (LDST8_ABS_LO12_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LDST8_ABS_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Relocations for control-flow instructions. */ @@ -833,120 +922,120 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 14, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TSTBR14), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3fff, /* src_mask */ 0x3fff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* B.cond: ((S+A-P) >> 2) & 0x7ffff */ HOWTO (AARCH64_R (CONDBR19), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 19, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (CONDBR19), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x7ffff, /* src_mask */ 0x7ffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* B: ((S+A-P) >> 2) & 0x3ffffff */ HOWTO (AARCH64_R (JUMP26), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (JUMP26), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffffff, /* src_mask */ 0x3ffffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* BL: ((S+A-P) >> 2) & 0x3ffffff */ HOWTO (AARCH64_R (CALL26), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (CALL26), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffffff, /* src_mask */ 0x3ffffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* LD/ST16: (S+A) & 0xffe */ HOWTO (AARCH64_R (LDST16_ABS_LO12_NC), /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LDST16_ABS_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffe, /* src_mask */ 0xffe, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST32: (S+A) & 0xffc */ HOWTO (AARCH64_R (LDST32_ABS_LO12_NC), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LDST32_ABS_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffc, /* src_mask */ 0xffc, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST64: (S+A) & 0xff8 */ HOWTO (AARCH64_R (LDST64_ABS_LO12_NC), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LDST64_ABS_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xff8, /* src_mask */ 0xff8, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST128: (S+A) & 0xff0 */ HOWTO (AARCH64_R (LDST128_ABS_LO12_NC), /* type */ 4, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LDST128_ABS_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xff0, /* src_mask */ 0xff0, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Set a load-literal immediate field to bits 0x1FFFFC of G(S)-P */ @@ -954,15 +1043,15 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 2, /* rightshift */ 2, /* size (0 = byte,1 = short,2 = long) */ 19, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (GOT_LD_PREL19), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffffe0, /* src_mask */ 0xffffe0, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* Get to the page for the GOT entry for the symbol (G(S) - P) using an ADRP instruction. */ @@ -970,90 +1059,90 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (ADR_GOT_PAGE), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* LD64: GOT offset G(S) & 0xff8 */ HOWTO64 (AARCH64_R (LD64_GOT_LO12_NC), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LD64_GOT_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xff8, /* src_mask */ 0xff8, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD32: GOT offset G(S) & 0xffc */ HOWTO32 (AARCH64_R (LD32_GOT_LO12_NC), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LD32_GOT_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffc, /* src_mask */ 0xffc, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Lower 16 bits of GOT offset for the symbol. */ HOWTO64 (AARCH64_R (MOVW_GOTOFF_G0_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_GOTOFF_G0_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Higher 16 bits of GOT offset for the symbol. */ HOWTO64 (AARCH64_R (MOVW_GOTOFF_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (MOVW_GOTOFF_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD64: GOT offset for the symbol. */ HOWTO64 (AARCH64_R (LD64_GOTOFF_LO15), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LD64_GOTOFF_LO15), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x7ff8, /* src_mask */ 0x7ff8, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD32: GOT offset to the page address of GOT table. (G(S) - PAGE (_GLOBAL_OFFSET_TABLE_)) & 0x5ffc. */ @@ -1061,15 +1150,15 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LD32_GOTPAGE_LO14), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x5ffc, /* src_mask */ 0x5ffc, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD64: GOT offset to the page address of GOT table. (G(S) - PAGE (_GLOBAL_OFFSET_TABLE_)) & 0x7ff8. */ @@ -1077,15 +1166,15 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (LD64_GOTPAGE_LO15), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x7ff8, /* src_mask */ 0x7ff8, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Get to the page for the GOT entry for the symbol (G(S) - P) using an ADRP instruction. */ @@ -1093,218 +1182,218 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSGD_ADR_PAGE21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ HOWTO (AARCH64_R (TLSGD_ADR_PREL21), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSGD_ADR_PREL21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* ADD: GOT offset G(S) & 0xff8 [no overflow check] */ HOWTO (AARCH64_R (TLSGD_ADD_LO12_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSGD_ADD_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Lower 16 bits of GOT offset to tls_index. */ HOWTO64 (AARCH64_R (TLSGD_MOVW_G0_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSGD_MOVW_G0_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Higher 16 bits of GOT offset to tls_index. */ HOWTO64 (AARCH64_R (TLSGD_MOVW_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSGD_MOVW_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSIE_ADR_GOTTPREL_PAGE21), /* type */ 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSIE_ADR_GOTTPREL_PAGE21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSIE_LD64_GOTTPREL_LO12_NC), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSIE_LD64_GOTTPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xff8, /* src_mask */ 0xff8, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO32 (AARCH64_R (TLSIE_LD32_GOTTPREL_LO12_NC), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSIE_LD32_GOTTPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffc, /* src_mask */ 0xffc, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSIE_LD_GOTTPREL_PREL19), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 19, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSIE_LD_GOTTPREL_PREL19), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1ffffc, /* src_mask */ 0x1ffffc, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSIE_MOVW_GOTTPREL_G0_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G0_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSIE_MOVW_GOTTPREL_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* ADD: bit[23:12] of byte offset to module TLS base address. */ HOWTO (AARCH64_R (TLSLD_ADD_DTPREL_HI12), /* type */ 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_ADD_DTPREL_HI12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Unsigned 12 bit byte offset to module TLS base address. */ HOWTO (AARCH64_R (TLSLD_ADD_DTPREL_LO12), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_ADD_DTPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* No overflow check version of BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12. */ HOWTO (AARCH64_R (TLSLD_ADD_DTPREL_LO12_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_ADD_DTPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* ADD: GOT offset G(S) & 0xff8 [no overflow check] */ HOWTO (AARCH64_R (TLSLD_ADD_LO12_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_ADD_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Get to the page for the GOT entry for the symbol (G(S) - P) using an ADRP instruction. */ @@ -1312,484 +1401,484 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_ADR_PAGE21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ HOWTO (AARCH64_R (TLSLD_ADR_PREL21), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_ADR_PREL21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* LD/ST16: bit[11:1] of byte offset to module TLS base address. */ HOWTO64 (AARCH64_R (TLSLD_LDST16_DTPREL_LO12), /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 11, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_LDST16_DTPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1ffc00, /* src_mask */ 0x1ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Same as BFD_RELOC_AARCH64_TLSLD_LDST16_DTPREL_LO12, but no overflow check. */ HOWTO64 (AARCH64_R (TLSLD_LDST16_DTPREL_LO12_NC), /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 11, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_LDST16_DTPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1ffc00, /* src_mask */ 0x1ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST32: bit[11:2] of byte offset to module TLS base address. */ HOWTO64 (AARCH64_R (TLSLD_LDST32_DTPREL_LO12), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 10, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_LDST32_DTPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffc00, /* src_mask */ 0x3ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Same as BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12, but no overflow check. */ HOWTO64 (AARCH64_R (TLSLD_LDST32_DTPREL_LO12_NC), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 10, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_LDST32_DTPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffc00, /* src_mask */ 0xffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST64: bit[11:3] of byte offset to module TLS base address. */ HOWTO64 (AARCH64_R (TLSLD_LDST64_DTPREL_LO12), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 9, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_LDST64_DTPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffc00, /* src_mask */ 0x3ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Same as BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12, but no overflow check. */ HOWTO64 (AARCH64_R (TLSLD_LDST64_DTPREL_LO12_NC), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 9, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_LDST64_DTPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x7fc00, /* src_mask */ 0x7fc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST8: bit[11:0] of byte offset to module TLS base address. */ HOWTO64 (AARCH64_R (TLSLD_LDST8_DTPREL_LO12), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_LDST8_DTPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffc00, /* src_mask */ 0x3ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Same as BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12, but no overflow check. */ HOWTO64 (AARCH64_R (TLSLD_LDST8_DTPREL_LO12_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_LDST8_DTPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffc00, /* src_mask */ 0x3ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVZ: bit[15:0] of byte offset to module TLS base address. */ HOWTO (AARCH64_R (TLSLD_MOVW_DTPREL_G0), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_MOVW_DTPREL_G0), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0. */ HOWTO (AARCH64_R (TLSLD_MOVW_DTPREL_G0_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_MOVW_DTPREL_G0_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVZ: bit[31:16] of byte offset to module TLS base address. */ HOWTO (AARCH64_R (TLSLD_MOVW_DTPREL_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_MOVW_DTPREL_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* No overflow check version of BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1. */ HOWTO64 (AARCH64_R (TLSLD_MOVW_DTPREL_G1_NC), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_MOVW_DTPREL_G1_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* MOVZ: bit[47:32] of byte offset to module TLS base address. */ HOWTO64 (AARCH64_R (TLSLD_MOVW_DTPREL_G2), /* type */ 32, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLD_MOVW_DTPREL_G2), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSLE_MOVW_TPREL_G2), /* type */ 32, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_MOVW_TPREL_G2), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_MOVW_TPREL_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSLE_MOVW_TPREL_G1_NC), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_MOVW_TPREL_G1_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G0), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_MOVW_TPREL_G0), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G0_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_MOVW_TPREL_G0_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSLE_ADD_TPREL_HI12), /* type */ 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_ADD_TPREL_HI12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSLE_ADD_TPREL_LO12), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_ADD_TPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSLE_ADD_TPREL_LO12_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_ADD_TPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST16: bit[11:1] of byte offset to module TLS base address. */ HOWTO (AARCH64_R (TLSLE_LDST16_TPREL_LO12), /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 11, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_LDST16_TPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1ffc00, /* src_mask */ 0x1ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Same as BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12, but no overflow check. */ HOWTO (AARCH64_R (TLSLE_LDST16_TPREL_LO12_NC), /* type */ 1, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 11, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_LDST16_TPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1ffc00, /* src_mask */ 0x1ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST32: bit[11:2] of byte offset to module TLS base address. */ HOWTO (AARCH64_R (TLSLE_LDST32_TPREL_LO12), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 10, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_LDST32_TPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffc00, /* src_mask */ 0xffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Same as BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12, but no overflow check. */ HOWTO (AARCH64_R (TLSLE_LDST32_TPREL_LO12_NC), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 10, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_LDST32_TPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffc00, /* src_mask */ 0xffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST64: bit[11:3] of byte offset to module TLS base address. */ HOWTO (AARCH64_R (TLSLE_LDST64_TPREL_LO12), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 9, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_LDST64_TPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x7fc00, /* src_mask */ 0x7fc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Same as BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12, but no overflow check. */ HOWTO (AARCH64_R (TLSLE_LDST64_TPREL_LO12_NC), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 9, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_LDST64_TPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x7fc00, /* src_mask */ 0x7fc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD/ST8: bit[11:0] of byte offset to module TLS base address. */ HOWTO (AARCH64_R (TLSLE_LDST8_TPREL_LO12), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_LDST8_TPREL_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffc00, /* src_mask */ 0x3ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Same as BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12, but no overflow check. */ HOWTO (AARCH64_R (TLSLE_LDST8_TPREL_LO12_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 10, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSLE_LDST8_TPREL_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x3ffc00, /* src_mask */ 0x3ffc00, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSDESC_LD_PREL19), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 19, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_LD_PREL19), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x0ffffe0, /* src_mask */ 0x0ffffe0, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ HOWTO (AARCH64_R (TLSDESC_ADR_PREL21), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_ADR_PREL21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* Get to the page for the GOT entry for the symbol (G(S) - P) using an ADRP instruction. */ @@ -1797,192 +1886,192 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 12, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 21, /* bitsize */ - TRUE, /* pc_relative */ + true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_ADR_PAGE21), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x1fffff, /* src_mask */ 0x1fffff, /* dst_mask */ - TRUE), /* pcrel_offset */ + true), /* pcrel_offset */ /* LD64: GOT offset G(S) & 0xff8. */ HOWTO64 (AARCH64_R (TLSDESC_LD64_LO12), /* type */ 3, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_LD64_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xff8, /* src_mask */ 0xff8, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* LD32: GOT offset G(S) & 0xffc. */ HOWTO32 (AARCH64_R (TLSDESC_LD32_LO12_NC), /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_LD32_LO12_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffc, /* src_mask */ 0xffc, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* ADD: GOT offset G(S) & 0xfff. */ HOWTO (AARCH64_R (TLSDESC_ADD_LO12), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont,/* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_ADD_LO12), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xfff, /* src_mask */ 0xfff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSDESC_OFF_G1), /* type */ 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_unsigned, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_OFF_G1), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSDESC_OFF_G0_NC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_OFF_G0_NC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSDESC_LDR), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_LDR), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x0, /* src_mask */ 0x0, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO64 (AARCH64_R (TLSDESC_ADD), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 12, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_ADD), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x0, /* src_mask */ 0x0, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSDESC_CALL), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC_CALL), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0x0, /* src_mask */ 0x0, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (COPY), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (COPY), /* name */ - TRUE, /* partial_inplace */ + true, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (GLOB_DAT), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (GLOB_DAT), /* name */ - TRUE, /* partial_inplace */ + true, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (JUMP_SLOT), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (JUMP_SLOT), /* name */ - TRUE, /* partial_inplace */ + true, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (RELATIVE), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (RELATIVE), /* name */ - TRUE, /* partial_inplace */ + true, /* partial_inplace */ ALL_ONES, /* src_mask */ ALL_ONES, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLS_DTPMOD), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ @@ -1991,16 +2080,16 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = #else AARCH64_R_STR (TLS_DTPMOD), /* name */ #endif - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ ALL_ONES, /* dst_mask */ - FALSE), /* pc_reloffset */ + false), /* pc_reloffset */ HOWTO (AARCH64_R (TLS_DTPREL), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ @@ -2009,16 +2098,16 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = #else AARCH64_R_STR (TLS_DTPREL), /* name */ #endif - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ ALL_ONES, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLS_TPREL), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ @@ -2027,38 +2116,38 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = #else AARCH64_R_STR (TLS_TPREL), /* name */ #endif - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ ALL_ONES, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (TLSDESC), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (TLSDESC), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ ALL_ONES, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (AARCH64_R (IRELATIVE), /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ AARCH64_R_STR (IRELATIVE), /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ ALL_ONES, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ EMPTY_HOWTO (0), }; @@ -2068,15 +2157,15 @@ static reloc_howto_type elfNN_aarch64_howto_none = 0, /* rightshift */ 3, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont,/* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_AARCH64_NONE", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - FALSE); /* pcrel_offset */ + false); /* pcrel_offset */ /* Given HOWTO, return the bfd internal relocation enumerator. */ @@ -2102,7 +2191,7 @@ elfNN_aarch64_bfd_reloc_from_howto (reloc_howto_type *howto) static bfd_reloc_code_real_type elfNN_aarch64_bfd_reloc_from_type (bfd *abfd, unsigned int r_type) { - static bfd_boolean initialized_p = FALSE; + static bool initialized_p = false; /* Indexed by R_TYPE, values are offsets in the howto_table. */ static unsigned int offsets[R_AARCH64_end]; @@ -2114,7 +2203,7 @@ elfNN_aarch64_bfd_reloc_from_type (bfd *abfd, unsigned int r_type) if (elfNN_aarch64_howto_table[i].type != 0) offsets[elfNN_aarch64_howto_table[i].type] = i; - initialized_p = TRUE; + initialized_p = true; } if (r_type == R_AARCH64_NONE || r_type == R_AARCH64_NULL) @@ -2209,7 +2298,7 @@ elfNN_aarch64_howto_from_type (bfd *abfd, unsigned int r_type) return NULL; } -static bfd_boolean +static bool elfNN_aarch64_info_to_howto (bfd *abfd, arelent *bfd_reloc, Elf_Internal_Rela *elf_reloc) { @@ -2222,9 +2311,9 @@ elfNN_aarch64_info_to_howto (bfd *abfd, arelent *bfd_reloc, { /* xgettext:c-format */ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); - return FALSE; + return false; } - return TRUE; + return true; } static reloc_howto_type * @@ -2436,6 +2525,16 @@ struct elf_aarch64_obj_tdata /* Zero to warn when linking objects with incompatible wchar_t sizes. */ int no_wchar_size_warning; + + /* All GNU_PROPERTY_AARCH64_FEATURE_1_AND properties. */ + uint32_t gnu_and_prop; + + /* Zero to warn when linking objects with incompatible + GNU_PROPERTY_AARCH64_FEATURE_1_BTI. */ + int no_bti_warn; + + /* PLT type based on security. */ + aarch64_plt_type plt_type; }; #define elf_aarch64_tdata(bfd) \ @@ -2448,7 +2547,7 @@ struct elf_aarch64_obj_tdata && elf_tdata (bfd) != NULL \ && elf_object_id (bfd) == AARCH64_ELF_DATA) -static bfd_boolean +static bool elfNN_aarch64_mkobject (bfd *abfd) { return bfd_elf_allocate_object (abfd, sizeof (struct elf_aarch64_obj_tdata), @@ -2471,9 +2570,6 @@ struct elf_aarch64_link_hash_entry { struct elf_link_hash_entry root; - /* Track dynamic relocs copied for this symbol. */ - struct elf_dyn_relocs *dyn_relocs; - /* Since PLT entries have variable size, we need to record the index into .got.plt instead of recomputing it from the PLT offset. */ @@ -2530,10 +2626,7 @@ struct elf_aarch64_link_hash_table int fix_erratum_835769; /* Fix erratum 843419. */ - int fix_erratum_843419; - - /* Enable ADRP->ADR rewrite for erratum 843419 workaround. */ - int fix_erratum_843419_adr; + erratum_84319_opts fix_erratum_843419; /* Don't apply link-time values for dynamic relocations. */ int no_apply_dynamic_relocs; @@ -2541,11 +2634,14 @@ struct elf_aarch64_link_hash_table /* The number of bytes in the initial entry in the PLT. */ bfd_size_type plt_header_size; - /* The number of bytes in the subsequent PLT etries. */ + /* The bytes of the initial PLT entry. */ + const bfd_byte *plt0_entry; + + /* The number of bytes in the subsequent PLT entries. */ bfd_size_type plt_entry_size; - /* Small local sym cache. */ - struct sym_cache sym_cache; + /* The bytes of the subsequent PLT entry. */ + const bfd_byte *plt_entry; /* For convenience in allocate_dynrelocs. */ bfd *obfd; @@ -2580,16 +2676,11 @@ struct elf_aarch64_link_hash_table unsigned int top_index; asection **input_list; - /* The offset into splt of the PLT entry for the TLS descriptor - resolver. Special values are 0, if not necessary (or not found - to be necessary yet), and -1 if needed but not determined - yet. */ - bfd_vma tlsdesc_plt; + /* JUMP_SLOT relocs for variant PCS symbols may be present. */ + int variant_pcs; - /* The GOT offset for the lazy trampoline. Communicated to the - loader via DT_TLSDESC_GOT. The magic value (bfd_vma) -1 - indicates an offset is not allocated. */ - bfd_vma dt_tlsdesc_got; + /* The number of bytes in the PLT enty for the TLS descriptor. */ + bfd_size_type tlsdesc_plt_entry_size; /* Used by local STT_GNU_IFUNC symbols. */ htab_t loc_hash_table; @@ -2620,7 +2711,6 @@ elfNN_aarch64_link_hash_newfunc (struct bfd_hash_entry *entry, table, string)); if (ret != NULL) { - ret->dyn_relocs = NULL; ret->got_type = GOT_UNKNOWN; ret->plt_got_offset = (bfd_vma) - 1; ret->stub_cache = NULL; @@ -2699,7 +2789,7 @@ elfNN_aarch64_local_htab_eq (const void *ptr1, const void *ptr2) static struct elf_link_hash_entry * elfNN_aarch64_get_local_sym_hash (struct elf_aarch64_link_hash_table *htab, bfd *abfd, const Elf_Internal_Rela *rel, - bfd_boolean create) + bool create) { struct elf_aarch64_link_hash_entry e, *ret; asection *sec = abfd->sections; @@ -2747,37 +2837,6 @@ elfNN_aarch64_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_aarch64_link_hash_entry *) dir; eind = (struct elf_aarch64_link_hash_entry *) ind; - if (eind->dyn_relocs != NULL) - { - if (edir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &eind->dyn_relocs; (p = *pp) != NULL;) - { - struct elf_dyn_relocs *q; - - for (q = edir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = edir->dyn_relocs; - } - - edir->dyn_relocs = eind->dyn_relocs; - eind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect) { /* Copy over PLT info. */ @@ -2791,6 +2850,31 @@ elfNN_aarch64_copy_indirect_symbol (struct bfd_link_info *info, _bfd_elf_link_hash_copy_indirect (info, dir, ind); } +/* Merge non-visibility st_other attributes. */ + +static void +elfNN_aarch64_merge_symbol_attribute (struct elf_link_hash_entry *h, + unsigned int st_other, + bool definition ATTRIBUTE_UNUSED, + bool dynamic ATTRIBUTE_UNUSED) +{ + unsigned int isym_sto = st_other & ~ELF_ST_VISIBILITY (-1); + unsigned int h_sto = h->other & ~ELF_ST_VISIBILITY (-1); + + if (isym_sto == h_sto) + return; + + if (isym_sto & ~STO_AARCH64_VARIANT_PCS) + /* Not fatal, this callback cannot fail. */ + _bfd_error_handler (_("unknown attribute for symbol `%s': 0x%02x"), + h->root.root.string, isym_sto); + + /* Note: Ideally we would warn about any attribute mismatch, but + this api does not allow that without substantial changes. */ + if (isym_sto & STO_AARCH64_VARIANT_PCS) + h->other |= STO_AARCH64_VARIANT_PCS; +} + /* Destroy an AArch64 elf linker hash table. */ static void @@ -2814,7 +2898,7 @@ static struct bfd_link_hash_table * elfNN_aarch64_link_hash_table_create (bfd *abfd) { struct elf_aarch64_link_hash_table *ret; - bfd_size_type amt = sizeof (struct elf_aarch64_link_hash_table); + size_t amt = sizeof (struct elf_aarch64_link_hash_table); ret = bfd_zmalloc (amt); if (ret == NULL) @@ -2829,9 +2913,12 @@ elfNN_aarch64_link_hash_table_create (bfd *abfd) } ret->plt_header_size = PLT_ENTRY_SIZE; + ret->plt0_entry = elfNN_aarch64_small_plt0_entry; ret->plt_entry_size = PLT_SMALL_ENTRY_SIZE; + ret->plt_entry = elfNN_aarch64_small_plt_entry; + ret->tlsdesc_plt_entry_size = PLT_TLSDESC_ENTRY_SIZE; ret->obfd = abfd; - ret->dt_tlsdesc_got = (bfd_vma) - 1; + ret->root.tlsdesc_got = (bfd_vma) - 1; if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc, sizeof (struct elf_aarch64_stub_hash_entry))) @@ -2857,7 +2944,7 @@ elfNN_aarch64_link_hash_table_create (bfd *abfd) /* Perform relocation R_TYPE. Returns TRUE upon success, FALSE otherwise. */ -static bfd_boolean +static bool aarch64_relocate (unsigned int r_type, bfd *input_bfd, asection *input_section, bfd_vma offset, bfd_vma value) { @@ -2869,7 +2956,8 @@ aarch64_relocate (unsigned int r_type, bfd *input_bfd, asection *input_section, + offset); r_type = elfNN_aarch64_bfd_reloc_from_type (input_bfd, r_type); - value = _bfd_aarch64_elf_resolve_relocation (r_type, place, value, 0, FALSE); + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, r_type, place, + value, 0, false); return _bfd_aarch64_elf_put_addend (input_bfd, input_section->contents + offset, r_type, howto, value) == bfd_reloc_ok; @@ -2962,13 +3050,13 @@ elfNN_aarch64_stub_name (const asection *input_section, executable PLT slots where the executable never takes the address of those functions, the function symbols are not added to the hash table. */ -static bfd_boolean +static bool elf_aarch64_hash_symbol (struct elf_link_hash_entry *h) { if (h->plt.offset != (bfd_vma) -1 && !h->def_regular && !h->pointer_equality_needed) - return FALSE; + return false; return _bfd_elf_hash_symbol (h); } @@ -3013,7 +3101,7 @@ elfNN_aarch64_get_stub_entry (const asection *input_section, return NULL; stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table, - stub_name, FALSE, FALSE); + stub_name, false, false); if (h != NULL) h->stub_cache = stub_entry; @@ -3092,7 +3180,7 @@ _bfd_aarch64_add_stub_entry_in_group (const char *stub_name, /* Enter this entry into the linker stub hash table. */ stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table, stub_name, - TRUE, FALSE); + true, false); if (stub_entry == NULL) { /* xgettext:c-format */ @@ -3119,9 +3207,12 @@ _bfd_aarch64_add_stub_entry_after (const char *stub_name, asection *stub_sec; struct elf_aarch64_stub_hash_entry *stub_entry; - stub_sec = _bfd_aarch64_get_stub_for_link_section (link_section, htab); + stub_sec = NULL; + /* Only create the actual stub if we will end up needing it. */ + if (htab->fix_erratum_843419 & ERRAT_ADRP) + stub_sec = _bfd_aarch64_get_stub_for_link_section (link_section, htab); stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table, stub_name, - TRUE, FALSE); + true, false); if (stub_entry == NULL) { _bfd_error_handler (_("cannot create stub entry %s"), stub_name); @@ -3136,9 +3227,9 @@ _bfd_aarch64_add_stub_entry_after (const char *stub_name, } -static bfd_boolean +static bool aarch64_build_one_stub (struct bfd_hash_entry *gen_entry, - void *in_arg ATTRIBUTE_UNUSED) + void *in_arg) { struct elf_aarch64_stub_hash_entry *stub_entry; asection *stub_sec; @@ -3151,10 +3242,22 @@ aarch64_build_one_stub (struct bfd_hash_entry *gen_entry, unsigned int template_size; const uint32_t *template; unsigned int i; + struct bfd_link_info *info; /* Massage our args to the form they really have. */ stub_entry = (struct elf_aarch64_stub_hash_entry *) gen_entry; + info = (struct bfd_link_info *) in_arg; + + /* Fail if the target section could not be assigned to an output + section. The user should fix his linker script. */ + if (stub_entry->target_section->output_section == NULL + && info->non_contiguous_regions) + info->callbacks->einfo (_("%F%P: Could not assign '%pA' to an output section. " + "Retry without " + "--enable-non-contiguous-regions.\n"), + stub_entry->target_section); + stub_sec = stub_entry->stub_sec; /* Make a note of the offset within the stubs for this entry. */ @@ -3257,21 +3360,22 @@ aarch64_build_one_stub (struct bfd_hash_entry *gen_entry, abort (); } - return TRUE; + return true; } /* As above, but don't actually build the stub. Just bump offset so we know stub section sizes. */ -static bfd_boolean -aarch64_size_one_stub (struct bfd_hash_entry *gen_entry, - void *in_arg ATTRIBUTE_UNUSED) +static bool +aarch64_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) { struct elf_aarch64_stub_hash_entry *stub_entry; + struct elf_aarch64_link_hash_table *htab; int size; /* Massage our args to the form they really have. */ stub_entry = (struct elf_aarch64_stub_hash_entry *) gen_entry; + htab = (struct elf_aarch64_link_hash_table *) in_arg; switch (stub_entry->stub_type) { @@ -3285,7 +3389,11 @@ aarch64_size_one_stub (struct bfd_hash_entry *gen_entry, size = sizeof (aarch64_erratum_835769_stub); break; case aarch64_stub_erratum_843419_veneer: - size = sizeof (aarch64_erratum_843419_stub); + { + if (htab->fix_erratum_843419 == ERRAT_ADR) + return true; + size = sizeof (aarch64_erratum_843419_stub); + } break; default: abort (); @@ -3293,7 +3401,7 @@ aarch64_size_one_stub (struct bfd_hash_entry *gen_entry, size = (size + 7) & ~7; stub_entry->stub_sec->size += size; - return TRUE; + return true; } /* External entry points for sizing and building linker stubs. */ @@ -3311,11 +3419,11 @@ elfNN_aarch64_setup_section_lists (bfd *output_bfd, unsigned int top_id, top_index; asection *section; asection **input_list, **list; - bfd_size_type amt; + size_t amt; struct elf_aarch64_link_hash_table *htab = elf_aarch64_hash_table (info); - if (!is_elf_hash_table (htab)) + if (!is_elf_hash_table (&htab->root.root)) return 0; /* Count the number of input BFDs and find the top input section id. */ @@ -3389,7 +3497,7 @@ elfNN_aarch64_next_input_section (struct bfd_link_info *info, asection *isec) { asection **list = htab->input_list + isec->output_section->index; - if (*list != bfd_abs_section_ptr) + if (*list != bfd_abs_section_ptr && (isec->flags & SEC_CODE) != 0) { /* Steal the link_sec pointer for our list. */ /* This happens to make the list in reverse order, @@ -3410,67 +3518,96 @@ elfNN_aarch64_next_input_section (struct bfd_link_info *info, asection *isec) static void group_sections (struct elf_aarch64_link_hash_table *htab, bfd_size_type stub_group_size, - bfd_boolean stubs_always_before_branch) + bool stubs_always_after_branch) { - asection **list = htab->input_list + htab->top_index; + asection **list = htab->input_list; do { asection *tail = *list; + asection *head; if (tail == bfd_abs_section_ptr) continue; + /* Reverse the list: we must avoid placing stubs at the + beginning of the section because the beginning of the text + section may be required for an interrupt vector in bare metal + code. */ +#define NEXT_SEC PREV_SEC + head = NULL; while (tail != NULL) + { + /* Pop from tail. */ + asection *item = tail; + tail = PREV_SEC (item); + + /* Push on head. */ + NEXT_SEC (item) = head; + head = item; + } + + while (head != NULL) { asection *curr; - asection *prev; - bfd_size_type total; + asection *next; + bfd_vma stub_group_start = head->output_offset; + bfd_vma end_of_next; - curr = tail; - total = tail->size; - while ((prev = PREV_SEC (curr)) != NULL - && ((total += curr->output_offset - prev->output_offset) - < stub_group_size)) - curr = prev; + curr = head; + while (NEXT_SEC (curr) != NULL) + { + next = NEXT_SEC (curr); + end_of_next = next->output_offset + next->size; + if (end_of_next - stub_group_start >= stub_group_size) + /* End of NEXT is too far from start, so stop. */ + break; + /* Add NEXT to the group. */ + curr = next; + } - /* OK, the size from the start of CURR to the end is less + /* OK, the size from the start to the start of CURR is less than stub_group_size and thus can be handled by one stub - section. (Or the tail section is itself larger than + section. (Or the head section is itself larger than stub_group_size, in which case we may be toast.) We should really be keeping track of the total size of stubs added here, as stubs contribute to the final output section size. */ do { - prev = PREV_SEC (tail); + next = NEXT_SEC (head); /* Set up this stub group. */ - htab->stub_group[tail->id].link_sec = curr; + htab->stub_group[head->id].link_sec = curr; } - while (tail != curr && (tail = prev) != NULL); + while (head != curr && (head = next) != NULL); /* But wait, there's more! Input sections up to stub_group_size - bytes before the stub section can be handled by it too. */ - if (!stubs_always_before_branch) + bytes after the stub section can be handled by it too. */ + if (!stubs_always_after_branch) { - total = 0; - while (prev != NULL - && ((total += tail->output_offset - prev->output_offset) - < stub_group_size)) + stub_group_start = curr->output_offset + curr->size; + + while (next != NULL) { - tail = prev; - prev = PREV_SEC (tail); - htab->stub_group[tail->id].link_sec = curr; + end_of_next = next->output_offset + next->size; + if (end_of_next - stub_group_start >= stub_group_size) + /* End of NEXT is too far from stubs, so stop. */ + break; + /* Add NEXT to the stub group. */ + head = next; + next = NEXT_SEC (head); + htab->stub_group[head->id].link_sec = curr; } } - tail = prev; + head = next; } } - while (list-- != htab->input_list); + while (list++ != htab->input_list + htab->top_index); free (htab->input_list); } +#undef PREV_SEC #undef PREV_SEC #define AARCH64_BITS(x, pos, n) (((x) >> (pos)) & ((1 << (n)) - 1)) @@ -3518,9 +3655,9 @@ group_sections (struct elf_aarch64_link_hash_table *htab, For LD/ST pair instructions PAIR is TRUE, RT and RT2 are returned. */ -static bfd_boolean +static bool aarch64_mem_op_p (uint32_t insn, unsigned int *rt, unsigned int *rt2, - bfd_boolean *pair, bfd_boolean *load) + bool *pair, bool *load) { uint32_t opcode; unsigned int r; @@ -3531,32 +3668,32 @@ aarch64_mem_op_p (uint32_t insn, unsigned int *rt, unsigned int *rt2, /* Bail out quickly if INSN doesn't fall into the load-store encoding space. */ if (!AARCH64_LDST (insn)) - return FALSE; + return false; - *pair = FALSE; - *load = FALSE; + *pair = false; + *load = false; if (AARCH64_LDST_EX (insn)) { *rt = AARCH64_RT (insn); *rt2 = *rt; if (AARCH64_BIT (insn, 21) == 1) { - *pair = TRUE; + *pair = true; *rt2 = AARCH64_RT2 (insn); } *load = AARCH64_LD (insn); - return TRUE; + return true; } else if (AARCH64_LDST_NAP (insn) || AARCH64_LDSTP_PI (insn) || AARCH64_LDSTP_O (insn) || AARCH64_LDSTP_PRE (insn)) { - *pair = TRUE; + *pair = true; *rt = AARCH64_RT (insn); *rt2 = AARCH64_RT2 (insn); *load = AARCH64_LD (insn); - return TRUE; + return true; } else if (AARCH64_LDST_PCREL (insn) || AARCH64_LDST_UI (insn) @@ -3569,13 +3706,13 @@ aarch64_mem_op_p (uint32_t insn, unsigned int *rt, unsigned int *rt2, *rt = AARCH64_RT (insn); *rt2 = *rt; if (AARCH64_LDST_PCREL (insn)) - *load = TRUE; + *load = true; opc = AARCH64_BITS (insn, 22, 2); v = AARCH64_BIT (insn, 26); opc_v = opc | (v << 2); *load = (opc_v == 1 || opc_v == 2 || opc_v == 3 || opc_v == 5 || opc_v == 7); - return TRUE; + return true; } else if (AARCH64_LDST_SIMD_M (insn) || AARCH64_LDST_SIMD_M_PI (insn)) @@ -3605,9 +3742,9 @@ aarch64_mem_op_p (uint32_t insn, unsigned int *rt, unsigned int *rt2, break; default: - return FALSE; + return false; } - return TRUE; + return true; } else if (AARCH64_LDST_SIMD_S (insn) || AARCH64_LDST_SIMD_S_PI (insn)) @@ -3639,17 +3776,17 @@ aarch64_mem_op_p (uint32_t insn, unsigned int *rt, unsigned int *rt2, break; default: - return FALSE; + return false; } - return TRUE; + return true; } - return FALSE; + return false; } /* Return TRUE if INSN is multiply-accumulate. */ -static bfd_boolean +static bool aarch64_mlxl_p (uint32_t insn) { uint32_t op31 = AARCH64_OP31 (insn); @@ -3659,9 +3796,9 @@ aarch64_mlxl_p (uint32_t insn) /* Exclude MUL instructions which are encoded as a multiple accumulate with RA = XZR. */ && AARCH64_RA (insn) != AARCH64_ZR) - return TRUE; + return true; - return FALSE; + return false; } /* Some early revisions of the Cortex-A53 have an erratum (835769) whereby @@ -3677,7 +3814,7 @@ aarch64_mlxl_p (uint32_t insn) operation (INSN_2). Return TRUE if an erratum sequence is found, FALSE if INSN_1 and INSN_2 are safe. */ -static bfd_boolean +static bool aarch64_erratum_sequence (uint32_t insn_1, uint32_t insn_2) { uint32_t rt; @@ -3685,8 +3822,8 @@ aarch64_erratum_sequence (uint32_t insn_1, uint32_t insn_2) uint32_t rn; uint32_t rm; uint32_t ra; - bfd_boolean pair; - bfd_boolean load; + bool pair; + bool load; if (aarch64_mlxl_p (insn_2) && aarch64_mem_op_p (insn_1, &rt, &rt2, &pair, &load)) @@ -3694,7 +3831,7 @@ aarch64_erratum_sequence (uint32_t insn_1, uint32_t insn_2) /* Any SIMD memory op is independent of the subsequent MLA by definition of the erratum. */ if (AARCH64_BIT (insn_1, 26)) - return TRUE; + return true; /* If not SIMD, check for integer memory ops and MLA relationship. */ rn = AARCH64_RN (insn_2); @@ -3706,14 +3843,14 @@ aarch64_erratum_sequence (uint32_t insn_1, uint32_t insn_2) if (load && (rt == rn || rt == rm || rt == ra || (pair && (rt2 == rn || rt2 == rm || rt2 == ra)))) - return FALSE; + return false; /* We conservatively put out stubs for all other cases (including writebacks). */ - return TRUE; + return true; } - return FALSE; + return false; } /* Used to order a list of mapping symbols by address. */ @@ -3754,7 +3891,7 @@ _bfd_aarch64_erratum_835769_stub_name (unsigned num_fixes) Return TRUE else FALSE on abnormal termination. */ -static bfd_boolean +static bool _bfd_aarch64_erratum_835769_scan (bfd *input_bfd, struct bfd_link_info *info, unsigned int *num_fixes_p) @@ -3764,7 +3901,7 @@ _bfd_aarch64_erratum_835769_scan (bfd *input_bfd, unsigned int num_fixes = *num_fixes_p; if (htab == NULL) - return TRUE; + return true; for (section = input_bfd->sections; section != NULL; @@ -3784,12 +3921,13 @@ _bfd_aarch64_erratum_835769_scan (bfd *input_bfd, if (elf_section_data (section)->this_hdr.contents != NULL) contents = elf_section_data (section)->this_hdr.contents; else if (! bfd_malloc_and_get_section (input_bfd, section, &contents)) - return FALSE; + return false; sec_data = elf_aarch64_section_data (section); - qsort (sec_data->map, sec_data->mapcount, - sizeof (elf_aarch64_section_map), elf_aarch64_compare_mapping); + if (sec_data->mapcount) + qsort (sec_data->map, sec_data->mapcount, + sizeof (elf_aarch64_section_map), elf_aarch64_compare_mapping); for (span = 0; span < sec_data->mapcount; span++) { @@ -3813,13 +3951,13 @@ _bfd_aarch64_erratum_835769_scan (bfd *input_bfd, struct elf_aarch64_stub_hash_entry *stub_entry; char *stub_name = _bfd_aarch64_erratum_835769_stub_name (num_fixes); if (! stub_name) - return FALSE; + return false; stub_entry = _bfd_aarch64_add_stub_entry_in_group (stub_name, section, htab); if (! stub_entry) - return FALSE; + return false; stub_entry->stub_type = aarch64_stub_erratum_835769_veneer; stub_entry->target_section = section; @@ -3836,13 +3974,13 @@ _bfd_aarch64_erratum_835769_scan (bfd *input_bfd, *num_fixes_p = num_fixes; - return TRUE; + return true; } /* Test if instruction INSN is ADRP. */ -static bfd_boolean +static bool _bfd_aarch64_adrp_p (uint32_t insn) { return ((insn & AARCH64_ADRP_OP_MASK) == AARCH64_ADRP_OP); @@ -3851,14 +3989,14 @@ _bfd_aarch64_adrp_p (uint32_t insn) /* Helper predicate to look for cortex-a53 erratum 843419 sequence 1. */ -static bfd_boolean +static bool _bfd_aarch64_erratum_843419_sequence_p (uint32_t insn_1, uint32_t insn_2, uint32_t insn_3) { uint32_t rt; uint32_t rt2; - bfd_boolean pair; - bfd_boolean load; + bool pair; + bool load; return (aarch64_mem_op_p (insn_2, &rt, &rt2, &pair, &load) && (!pair @@ -3876,7 +4014,7 @@ _bfd_aarch64_erratum_843419_sequence_p (uint32_t insn_1, uint32_t insn_2, instruction in the sequence. */ -static bfd_boolean +static bool _bfd_aarch64_erratum_843419_p (bfd_byte *contents, bfd_vma vma, bfd_vma i, bfd_vma span_end, bfd_vma *p_veneer_i) @@ -3884,35 +4022,35 @@ _bfd_aarch64_erratum_843419_p (bfd_byte *contents, bfd_vma vma, uint32_t insn_1 = bfd_getl32 (contents + i); if (!_bfd_aarch64_adrp_p (insn_1)) - return FALSE; + return false; if (span_end < i + 12) - return FALSE; + return false; uint32_t insn_2 = bfd_getl32 (contents + i + 4); uint32_t insn_3 = bfd_getl32 (contents + i + 8); if ((vma & 0xfff) != 0xff8 && (vma & 0xfff) != 0xffc) - return FALSE; + return false; if (_bfd_aarch64_erratum_843419_sequence_p (insn_1, insn_2, insn_3)) { *p_veneer_i = i + 8; - return TRUE; + return true; } if (span_end < i + 16) - return FALSE; + return false; uint32_t insn_4 = bfd_getl32 (contents + i + 12); if (_bfd_aarch64_erratum_843419_sequence_p (insn_1, insn_2, insn_4)) { *p_veneer_i = i + 12; - return TRUE; + return true; } - return FALSE; + return false; } @@ -3950,8 +4088,10 @@ _bfd_aarch64_resize_stubs (struct elf_aarch64_link_hash_table *htab) /* Ensure all stub sections have a size which is a multiple of 4096. This is important in order to ensure that the insertion of stub sections does not in itself move existing code around - in such a way that new errata sequences are created. */ - if (htab->fix_erratum_843419) + in such a way that new errata sequences are created. We only do this + when the ADRP workaround is enabled. If only the ADR workaround is + enabled then the stubs workaround won't ever be used. */ + if (htab->fix_erratum_843419 & ERRAT_ADRP) if (section->size) section->size = BFD_ALIGN (section->size, 0x1000); } @@ -3981,7 +4121,7 @@ _bfd_aarch64_erratum_843419_stub_name (asection *input_section, Returns TRUE on success. */ -static bfd_boolean +static bool _bfd_aarch64_erratum_843419_fixup (uint32_t insn, bfd_vma adrp_offset, bfd_vma ldst_offset, @@ -3994,13 +4134,13 @@ _bfd_aarch64_erratum_843419_fixup (uint32_t insn, stub_name = _bfd_aarch64_erratum_843419_stub_name (section, ldst_offset); if (stub_name == NULL) - return FALSE; + return false; stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table, stub_name, - FALSE, FALSE); + false, false); if (stub_entry) { free (stub_name); - return TRUE; + return true; } /* We always place an 843419 workaround veneer in the stub section @@ -4018,7 +4158,7 @@ _bfd_aarch64_erratum_843419_fixup (uint32_t insn, if (stub_entry == NULL) { free (stub_name); - return FALSE; + return false; } stub_entry->adrp_offset = adrp_offset; @@ -4028,7 +4168,7 @@ _bfd_aarch64_erratum_843419_fixup (uint32_t insn, stub_entry->veneered_insn = insn; stub_entry->output_name = stub_name; - return TRUE; + return true; } @@ -4041,21 +4181,21 @@ _bfd_aarch64_erratum_843419_fixup (uint32_t insn, Return TRUE on successful scan, FALSE on failure to scan. */ -static bfd_boolean +static bool _bfd_aarch64_erratum_843419_scan (bfd *input_bfd, asection *section, struct bfd_link_info *info) { struct elf_aarch64_link_hash_table *htab = elf_aarch64_hash_table (info); if (htab == NULL) - return TRUE; + return true; if (elf_section_type (section) != SHT_PROGBITS || (elf_section_flags (section) & SHF_EXECINSTR) == 0 || (section->flags & SEC_EXCLUDE) != 0 || (section->sec_info_type == SEC_INFO_TYPE_JUST_SYMS) || (section->output_section == bfd_abs_section_ptr)) - return TRUE; + return true; do { @@ -4066,12 +4206,13 @@ _bfd_aarch64_erratum_843419_scan (bfd *input_bfd, asection *section, if (elf_section_data (section)->this_hdr.contents != NULL) contents = elf_section_data (section)->this_hdr.contents; else if (! bfd_malloc_and_get_section (input_bfd, section, &contents)) - return FALSE; + return false; sec_data = elf_aarch64_section_data (section); - qsort (sec_data->map, sec_data->mapcount, - sizeof (elf_aarch64_section_map), elf_aarch64_compare_mapping); + if (sec_data->mapcount) + qsort (sec_data->map, sec_data->mapcount, + sizeof (elf_aarch64_section_map), elf_aarch64_compare_mapping); for (span = 0; span < sec_data->mapcount; span++) { @@ -4099,7 +4240,7 @@ _bfd_aarch64_erratum_843419_scan (bfd *input_bfd, asection *section, if (!_bfd_aarch64_erratum_843419_fixup (insn, i, veneer_i, section, info)) - return FALSE; + return false; } } } @@ -4109,7 +4250,7 @@ _bfd_aarch64_erratum_843419_scan (bfd *input_bfd, asection *section, } while (0); - return TRUE; + return true; } @@ -4119,7 +4260,7 @@ _bfd_aarch64_erratum_843419_scan (bfd *input_bfd, asection *section, PC-relative calls to a target that is unreachable with a "bl" instruction. */ -bfd_boolean +bool elfNN_aarch64_size_stubs (bfd *output_bfd, bfd *stub_bfd, struct bfd_link_info *info, @@ -4129,8 +4270,8 @@ elfNN_aarch64_size_stubs (bfd *output_bfd, void (*layout_sections_again) (void)) { bfd_size_type stub_group_size; - bfd_boolean stubs_always_before_branch; - bfd_boolean stub_changed = FALSE; + bool stubs_always_before_branch; + bool stub_changed = false; struct elf_aarch64_link_hash_table *htab = elf_aarch64_hash_table (info); unsigned int num_erratum_835769_fixes = 0; @@ -4166,15 +4307,21 @@ elfNN_aarch64_size_stubs (bfd *output_bfd, for (input_bfd = info->input_bfds; input_bfd != NULL; input_bfd = input_bfd->link.next) - if (!_bfd_aarch64_erratum_835769_scan (input_bfd, info, - &num_erratum_835769_fixes)) - return FALSE; + { + if (!is_aarch64_elf (input_bfd) + || (input_bfd->flags & BFD_LINKER_CREATED) != 0) + continue; + + if (!_bfd_aarch64_erratum_835769_scan (input_bfd, info, + &num_erratum_835769_fixes)) + return false; + } _bfd_aarch64_resize_stubs (htab); (*htab->layout_sections_again) (); } - if (htab->fix_erratum_843419) + if (htab->fix_erratum_843419 != ERRAT_NONE) { bfd *input_bfd; @@ -4184,11 +4331,15 @@ elfNN_aarch64_size_stubs (bfd *output_bfd, { asection *section; + if (!is_aarch64_elf (input_bfd) + || (input_bfd->flags & BFD_LINKER_CREATED) != 0) + continue; + for (section = input_bfd->sections; section != NULL; section = section->next) if (!_bfd_aarch64_erratum_843419_scan (input_bfd, section, info)) - return FALSE; + return false; } _bfd_aarch64_resize_stubs (htab); @@ -4206,6 +4357,10 @@ elfNN_aarch64_size_stubs (bfd *output_bfd, asection *section; Elf_Internal_Sym *local_syms = NULL; + if (!is_aarch64_elf (input_bfd) + || (input_bfd->flags & BFD_LINKER_CREATED) != 0) + continue; + /* We'll need the symbol table in a second. */ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; if (symtab_hdr->sh_info == 0) @@ -4409,7 +4564,7 @@ elfNN_aarch64_size_stubs (bfd *output_bfd, stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table, - stub_name, FALSE, FALSE); + stub_name, false, false); if (stub_entry != NULL) { /* The proper stub has already been created. */ @@ -4447,7 +4602,7 @@ elfNN_aarch64_size_stubs (bfd *output_bfd, snprintf (stub_entry->output_name, len, STUB_ENTRY_NAME, sym_name); - stub_changed = TRUE; + stub_changed = true; } /* We're done with the internal relocs, free them. */ @@ -4463,13 +4618,13 @@ elfNN_aarch64_size_stubs (bfd *output_bfd, /* Ask the linker to do its stuff. */ (*htab->layout_sections_again) (); - stub_changed = FALSE; + stub_changed = false; } - return TRUE; + return true; -error_ret_free_local: - return FALSE; + error_ret_free_local: + return false; } /* Build all the stubs associated with the current output file. The @@ -4478,7 +4633,7 @@ error_ret_free_local: functions here. This function is called via aarch64_elf_finish in the linker. */ -bfd_boolean +bool elfNN_aarch64_build_stubs (struct bfd_link_info *info) { asection *stub_sec; @@ -4500,7 +4655,7 @@ elfNN_aarch64_build_stubs (struct bfd_link_info *info) size = stub_sec->size; stub_sec->contents = bfd_zalloc (htab->stub_bfd, size); if (stub_sec->contents == NULL && size != 0) - return FALSE; + return false; stub_sec->size = 0; /* Add a branch around the stub section, and a nop, to keep it 8 byte @@ -4514,7 +4669,7 @@ elfNN_aarch64_build_stubs (struct bfd_link_info *info) table = &htab->stub_hash_table; bfd_hash_traverse (table, aarch64_build_one_stub, info); - return TRUE; + return true; } @@ -4597,6 +4752,47 @@ bfd_elfNN_aarch64_init_maps (bfd *abfd) } } +static void +setup_plt_values (struct bfd_link_info *link_info, + aarch64_plt_type plt_type) +{ + struct elf_aarch64_link_hash_table *globals; + globals = elf_aarch64_hash_table (link_info); + + if (plt_type == PLT_BTI_PAC) + { + globals->plt0_entry = elfNN_aarch64_small_plt0_bti_entry; + + /* Only in ET_EXEC we need PLTn with BTI. */ + if (bfd_link_pde (link_info)) + { + globals->plt_entry_size = PLT_BTI_PAC_SMALL_ENTRY_SIZE; + globals->plt_entry = elfNN_aarch64_small_plt_bti_pac_entry; + } + else + { + globals->plt_entry_size = PLT_PAC_SMALL_ENTRY_SIZE; + globals->plt_entry = elfNN_aarch64_small_plt_pac_entry; + } + } + else if (plt_type == PLT_BTI) + { + globals->plt0_entry = elfNN_aarch64_small_plt0_bti_entry; + + /* Only in ET_EXEC we need PLTn with BTI. */ + if (bfd_link_pde (link_info)) + { + globals->plt_entry_size = PLT_BTI_SMALL_ENTRY_SIZE; + globals->plt_entry = elfNN_aarch64_small_plt_bti_entry; + } + } + else if (plt_type == PLT_PAC) + { + globals->plt_entry_size = PLT_PAC_SMALL_ENTRY_SIZE; + globals->plt_entry = elfNN_aarch64_small_plt_pac_entry; + } +} + /* Set option values needed during linking. */ void bfd_elfNN_aarch64_set_options (struct bfd *output_bfd, @@ -4604,21 +4800,38 @@ bfd_elfNN_aarch64_set_options (struct bfd *output_bfd, int no_enum_warn, int no_wchar_warn, int pic_veneer, int fix_erratum_835769, - int fix_erratum_843419, - int no_apply_dynamic_relocs) + erratum_84319_opts fix_erratum_843419, + int no_apply_dynamic_relocs, + aarch64_bti_pac_info bp_info) { struct elf_aarch64_link_hash_table *globals; globals = elf_aarch64_hash_table (link_info); globals->pic_veneer = pic_veneer; globals->fix_erratum_835769 = fix_erratum_835769; + /* If the default options are used, then ERRAT_ADR will be set by default + which will enable the ADRP->ADR workaround for the erratum 843419 + workaround. */ globals->fix_erratum_843419 = fix_erratum_843419; - globals->fix_erratum_843419_adr = TRUE; globals->no_apply_dynamic_relocs = no_apply_dynamic_relocs; BFD_ASSERT (is_aarch64_elf (output_bfd)); elf_aarch64_tdata (output_bfd)->no_enum_size_warning = no_enum_warn; elf_aarch64_tdata (output_bfd)->no_wchar_size_warning = no_wchar_warn; + + switch (bp_info.bti_type) + { + case BTI_WARN: + elf_aarch64_tdata (output_bfd)->no_bti_warn = 0; + elf_aarch64_tdata (output_bfd)->gnu_and_prop + |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI; + break; + + default: + break; + } + elf_aarch64_tdata (output_bfd)->plt_type = bp_info.plt_type; + setup_plt_values (link_info, bp_info.plt_type); } static bfd_vma @@ -4626,11 +4839,11 @@ aarch64_calculate_got_entry_vma (struct elf_link_hash_entry *h, struct elf_aarch64_link_hash_table *globals, struct bfd_link_info *info, bfd_vma value, bfd *output_bfd, - bfd_boolean *unresolved_reloc_p) + bool *unresolved_reloc_p) { bfd_vma off = (bfd_vma) - 1; asection *basegot = globals->root.sgot; - bfd_boolean dyn = globals->root.dynamic_sections_created; + bool dyn = globals->root.dynamic_sections_created; if (h != NULL) { @@ -4661,7 +4874,7 @@ aarch64_calculate_got_entry_vma (struct elf_link_hash_entry *h, } } else - *unresolved_reloc_p = FALSE; + *unresolved_reloc_p = false; off = off + basegot->output_section->vma + basegot->output_offset; } @@ -4676,7 +4889,7 @@ static bfd_reloc_code_real_type aarch64_tls_transition_without_check (bfd_reloc_code_real_type r_type, struct elf_link_hash_entry *h) { - bfd_boolean is_local = h == NULL; + bool is_local = h == NULL; switch (r_type) { @@ -4814,7 +5027,7 @@ aarch64_reloc_got_type (bfd_reloc_code_real_type r_type) return GOT_UNKNOWN; } -static bfd_boolean +static bool aarch64_can_relax_tls (bfd *input_bfd, struct bfd_link_info *info, bfd_reloc_code_real_type r_type, @@ -4825,21 +5038,21 @@ aarch64_can_relax_tls (bfd *input_bfd, unsigned int reloc_got_type; if (! IS_AARCH64_TLS_RELAX_RELOC (r_type)) - return FALSE; + return false; symbol_got_type = elfNN_aarch64_symbol_got_type (h, input_bfd, r_symndx); reloc_got_type = aarch64_reloc_got_type (r_type); if (symbol_got_type == GOT_TLS_IE && GOT_TLS_GD_ANY_P (reloc_got_type)) - return TRUE; + return true; if (!bfd_link_executable (info)) - return FALSE; + return false; if (h && h->root.type == bfd_link_hash_undefweak) - return FALSE; + return false; - return TRUE; + return true; } /* Given the relocation code R_TYPE, return the relaxed bfd reloc @@ -4997,7 +5210,7 @@ struct erratum_835769_branch_to_stub_data /* Helper to insert branches to erratum 835769 stubs in the right places for a particular section. */ -static bfd_boolean +static bool make_branch_to_erratum_835769_stub (struct bfd_hash_entry *gen_entry, void *in_arg) { @@ -5015,7 +5228,7 @@ make_branch_to_erratum_835769_stub (struct bfd_hash_entry *gen_entry, if (stub_entry->target_section != data->output_section || stub_entry->stub_type != aarch64_stub_erratum_835769_veneer) - return TRUE; + return true; contents = data->contents; veneered_insn_loc = stub_entry->target_section->output_section->vma @@ -5039,11 +5252,11 @@ make_branch_to_erratum_835769_stub (struct bfd_hash_entry *gen_entry, branch_insn |= branch_offset; bfd_putl32 (branch_insn, &contents[target]); - return TRUE; + return true; } -static bfd_boolean +static bool _bfd_aarch64_erratum_843419_branch_to_stub (struct bfd_hash_entry *gen_entry, void *in_arg) { @@ -5067,11 +5280,20 @@ _bfd_aarch64_erratum_843419_branch_to_stub (struct bfd_hash_entry *gen_entry, if (stub_entry->target_section != section || stub_entry->stub_type != aarch64_stub_erratum_843419_veneer) - return TRUE; + return true; + + BFD_ASSERT (((htab->fix_erratum_843419 & ERRAT_ADRP) && stub_entry->stub_sec) + || (htab->fix_erratum_843419 & ERRAT_ADR)); - insn = bfd_getl32 (contents + stub_entry->target_value); - bfd_putl32 (insn, - stub_entry->stub_sec->contents + stub_entry->stub_offset); + /* Only update the stub section if we have one. We should always have one if + we're allowed to use the ADRP errata workaround, otherwise it is not + required. */ + if (stub_entry->stub_sec) + { + insn = bfd_getl32 (contents + stub_entry->target_value); + bfd_putl32 (insn, + stub_entry->stub_sec->contents + stub_entry->stub_offset); + } place = (section->output_section->vma + section->output_offset + stub_entry->adrp_offset); @@ -5085,14 +5307,16 @@ _bfd_aarch64_erratum_843419_branch_to_stub (struct bfd_hash_entry *gen_entry, ((bfd_vma) _bfd_aarch64_decode_adrp_imm (insn) << 12, 33) - (place & 0xfff)); - if (htab->fix_erratum_843419_adr + if ((htab->fix_erratum_843419 & ERRAT_ADR) && (imm >= AARCH64_MIN_ADRP_IMM && imm <= AARCH64_MAX_ADRP_IMM)) { insn = (_bfd_aarch64_reencode_adr_imm (AARCH64_ADR_OP, imm) | AARCH64_RT (insn)); bfd_putl32 (insn, contents + stub_entry->adrp_offset); + /* Stub is not needed, don't map it out. */ + stub_entry->stub_type = aarch64_stub_none; } - else + else if (htab->fix_erratum_843419 & ERRAT_ADRP) { bfd_vma veneered_insn_loc; bfd_vma veneer_entry_loc; @@ -5119,11 +5343,26 @@ _bfd_aarch64_erratum_843419_branch_to_stub (struct bfd_hash_entry *gen_entry, branch_insn |= branch_offset; bfd_putl32 (branch_insn, contents + stub_entry->target_value); } - return TRUE; + else + { + abfd = stub_entry->target_section->owner; + _bfd_error_handler + (_("%pB: error: erratum 843419 immediate 0x%" BFD_VMA_FMT "x " + "out of range for ADR (input file too large) and " + "--fix-cortex-a53-843419=adr used. Run the linker with " + "--fix-cortex-a53-843419=full instead"), abfd, imm); + bfd_set_error (bfd_error_bad_value); + /* This function is called inside a hashtable traversal and the error + handlers called above turn into non-fatal errors. Which means this + case ld returns an exit code 0 and also produces a broken object file. + To prevent this, issue a hard abort. */ + BFD_FAIL (); + } + return true; } -static bfd_boolean +static bool elfNN_aarch64_write_section (bfd *output_bfd ATTRIBUTE_UNUSED, struct bfd_link_info *link_info, asection *sec, @@ -5134,7 +5373,7 @@ elfNN_aarch64_write_section (bfd *output_bfd ATTRIBUTE_UNUSED, elf_aarch64_hash_table (link_info); if (globals == NULL) - return FALSE; + return false; /* Fix code to point to erratum 835769 stubs. */ if (globals->fix_erratum_835769) @@ -5159,12 +5398,12 @@ elfNN_aarch64_write_section (bfd *output_bfd ATTRIBUTE_UNUSED, _bfd_aarch64_erratum_843419_branch_to_stub, &data); } - return FALSE; + return false; } /* Return TRUE if RELOC is a relocation against the base of GOT table. */ -static bfd_boolean +static bool aarch64_relocation_aginst_gp_p (bfd_reloc_code_real_type reloc) { return (reloc == BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14 @@ -5188,8 +5427,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, struct bfd_link_info *info, asection *sym_sec, struct elf_link_hash_entry *h, - bfd_boolean *unresolved_reloc_p, - bfd_boolean save_addend, + bool *unresolved_reloc_p, + bool save_addend, bfd_vma *saved_addend, Elf_Internal_Sym *sym) { @@ -5202,12 +5441,12 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, bfd_vma place, off, got_entry_addr = 0; bfd_signed_vma signed_addend; struct elf_aarch64_link_hash_table *globals; - bfd_boolean weak_undef_p; - bfd_boolean relative_reloc; + bool weak_undef_p; + bool relative_reloc; asection *base_got; bfd_vma orig_value = value; - bfd_boolean resolved_to_zero; - bfd_boolean abs_symbol_p; + bool resolved_to_zero; + bool abs_symbol_p; globals = elf_aarch64_hash_table (info); @@ -5276,7 +5515,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, switch (bfd_r_type) { default: -bad_ifunc_reloc: + bad_ifunc_reloc: if (h->root.root.string) name = h->root.root.string; else @@ -5356,7 +5595,8 @@ bad_ifunc_reloc: /* FALLTHROUGH */ case BFD_RELOC_AARCH64_CALL26: case BFD_RELOC_AARCH64_JUMP26: - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, signed_addend, weak_undef_p); return _bfd_aarch64_elf_put_addend (input_bfd, hit_data, bfd_r_type, @@ -5433,7 +5673,8 @@ bad_ifunc_reloc: addend = (globals->root.sgot->output_section->vma + globals->root.sgot->output_offset); - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, addend, weak_undef_p); return _bfd_aarch64_elf_put_addend (input_bfd, hit_data, bfd_r_type, howto, value); case BFD_RELOC_AARCH64_ADD_LO12: @@ -5452,7 +5693,7 @@ bad_ifunc_reloc: case BFD_RELOC_AARCH64_TLSDESC_ADD: case BFD_RELOC_AARCH64_TLSDESC_CALL: case BFD_RELOC_AARCH64_TLSDESC_LDR: - *unresolved_reloc_p = FALSE; + *unresolved_reloc_p = false; return bfd_reloc_ok; case BFD_RELOC_AARCH64_NN: @@ -5483,24 +5724,24 @@ bad_ifunc_reloc: { Elf_Internal_Rela outrel; bfd_byte *loc; - bfd_boolean skip, relocate; + bool skip, relocate; asection *sreloc; - *unresolved_reloc_p = FALSE; + *unresolved_reloc_p = false; - skip = FALSE; - relocate = FALSE; + skip = false; + relocate = false; outrel.r_addend = signed_addend; outrel.r_offset = _bfd_elf_section_offset (output_bfd, info, input_section, rel->r_offset); if (outrel.r_offset == (bfd_vma) - 1) - skip = TRUE; + skip = true; else if (outrel.r_offset == (bfd_vma) - 2) { - skip = TRUE; - relocate = TRUE; + skip = true; + relocate = true; } else if (abs_symbol_p) { @@ -5528,7 +5769,7 @@ bad_ifunc_reloc: relocate the text and data segments independently, so the symbol does not matter. */ symbol = 0; - relocate = globals->no_apply_dynamic_relocs ? FALSE : TRUE; + relocate = !globals->no_apply_dynamic_relocs; outrel.r_info = ELFNN_R_INFO (symbol, AARCH64_R (RELATIVE)); outrel.r_addend += value; } @@ -5566,7 +5807,7 @@ bad_ifunc_reloc: case BFD_RELOC_AARCH64_JUMP26: { asection *splt = globals->root.splt; - bfd_boolean via_plt_p = + bool via_plt_p = splt != NULL && h != NULL && h->plt.offset != (bfd_vma) - 1; /* A call to an undefined weak symbol is converted to a jump to @@ -5611,9 +5852,10 @@ bad_ifunc_reloc: signed_addend = 0; } } - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, signed_addend, weak_undef_p); - *unresolved_reloc_p = FALSE; + *unresolved_reloc_p = false; break; case BFD_RELOC_AARCH64_16_PCREL: @@ -5647,6 +5889,23 @@ bad_ifunc_reloc: bfd_set_error (bfd_error_bad_value); return bfd_reloc_notsupported; } + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, + signed_addend, + weak_undef_p); + break; + + case BFD_RELOC_AARCH64_BRANCH19: + case BFD_RELOC_AARCH64_TSTBR14: + if (h && h->root.type == bfd_link_hash_undefined) + { + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB: conditional branch to undefined symbol `%s' " + "not allowed"), input_bfd, h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return bfd_reloc_notsupported; + } /* Fall through. */ case BFD_RELOC_AARCH64_16: @@ -5654,7 +5913,6 @@ bad_ifunc_reloc: case BFD_RELOC_AARCH64_32: #endif case BFD_RELOC_AARCH64_ADD_LO12: - case BFD_RELOC_AARCH64_BRANCH19: case BFD_RELOC_AARCH64_LDST128_LO12: case BFD_RELOC_AARCH64_LDST16_LO12: case BFD_RELOC_AARCH64_LDST32_LO12: @@ -5670,8 +5928,8 @@ bad_ifunc_reloc: case BFD_RELOC_AARCH64_MOVW_G2_NC: case BFD_RELOC_AARCH64_MOVW_G2_S: case BFD_RELOC_AARCH64_MOVW_G3: - case BFD_RELOC_AARCH64_TSTBR14: - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, signed_addend, weak_undef_p); break; @@ -5687,7 +5945,7 @@ bad_ifunc_reloc: if (globals->root.sgot == NULL) BFD_ASSERT (h != NULL); - relative_reloc = FALSE; + relative_reloc = false; if (h != NULL) { bfd_vma addend = 0; @@ -5703,7 +5961,7 @@ bad_ifunc_reloc: && h->root.type != bfd_link_hash_undefweak && bfd_link_pic (info) && !symbol_got_offset_mark_p (input_bfd, h, r_symndx)) - relative_reloc = TRUE; + relative_reloc = true; value = aarch64_calculate_got_entry_vma (h, globals, info, value, output_bfd, @@ -5716,7 +5974,8 @@ bad_ifunc_reloc: if (aarch64_relocation_aginst_gp_p (bfd_r_type)) addend = (globals->root.sgot->output_section->vma + globals->root.sgot->output_offset); - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, addend, weak_undef_p); } else @@ -5751,7 +6010,7 @@ bad_ifunc_reloc: base address. So, we need to generate a R_AARCH64_RELATIVE reloc for dynamic linker. */ if (bfd_link_pic (info)) - relative_reloc = TRUE; + relative_reloc = true; symbol_got_offset_mark (input_bfd, h, r_symndx); } @@ -5763,7 +6022,8 @@ bad_ifunc_reloc: if (aarch64_relocation_aginst_gp_p (bfd_r_type)) addend = base_got->output_section->vma + base_got->output_offset; - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, addend, weak_undef_p); } @@ -5800,9 +6060,10 @@ bad_ifunc_reloc: + globals->root.sgot->output_section->vma + globals->root.sgot->output_offset); - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, 0, weak_undef_p); - *unresolved_reloc_p = FALSE; + *unresolved_reloc_p = false; break; case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC: @@ -5813,9 +6074,10 @@ bad_ifunc_reloc: return bfd_reloc_notsupported; value = symbol_got_offset (input_bfd, h, r_symndx); - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, 0, weak_undef_p); - *unresolved_reloc_p = FALSE; + *unresolved_reloc_p = false; break; case BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12: @@ -5834,10 +6096,26 @@ bad_ifunc_reloc: case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1: case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC: case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2: - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, - signed_addend - dtpoff_base (info), - weak_undef_p); - break; + { + if (!(weak_undef_p || elf_hash_table (info)->tls_sec)) + { + int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB: TLS relocation %s against undefined symbol `%s'"), + input_bfd, elfNN_aarch64_howto_table[howto_index].name, + h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return bfd_reloc_notsupported; + } + + bfd_vma def_value + = weak_undef_p ? 0 : signed_addend - dtpoff_base (info); + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, + def_value, weak_undef_p); + break; + } case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12: @@ -5855,11 +6133,27 @@ bad_ifunc_reloc: case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1: case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC: case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2: - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, - signed_addend - tpoff_base (info), - weak_undef_p); - *unresolved_reloc_p = FALSE; - break; + { + if (!(weak_undef_p || elf_hash_table (info)->tls_sec)) + { + int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB: TLS relocation %s against undefined symbol `%s'"), + input_bfd, elfNN_aarch64_howto_table[howto_index].name, + h->root.root.string); + bfd_set_error (bfd_error_bad_value); + return bfd_reloc_notsupported; + } + + bfd_vma def_value + = weak_undef_p ? 0 : signed_addend - tpoff_base (info); + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, + def_value, weak_undef_p); + *unresolved_reloc_p = false; + break; + } case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12: case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21: @@ -5874,9 +6168,10 @@ bad_ifunc_reloc: + globals->root.sgotplt->output_offset + globals->sgotplt_jump_table_size); - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, 0, weak_undef_p); - *unresolved_reloc_p = FALSE; + *unresolved_reloc_p = false; break; case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC: @@ -5892,9 +6187,10 @@ bad_ifunc_reloc: value -= (globals->root.sgot->output_section->vma + globals->root.sgot->output_offset); - value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value, + value = _bfd_aarch64_elf_resolve_relocation (input_bfd, bfd_r_type, + place, value, 0, weak_undef_p); - *unresolved_reloc_p = FALSE; + *unresolved_reloc_p = false; break; default: @@ -5954,7 +6250,7 @@ struct erratum_843419_branch_to_stub_clear_data section inside IN_ARG matches. The clearing is done by setting the stub_type to none. */ -static bfd_boolean +static bool _bfd_aarch64_erratum_843419_clear_stub (struct bfd_hash_entry *gen_entry, void *in_arg) { @@ -5966,7 +6262,7 @@ _bfd_aarch64_erratum_843419_clear_stub (struct bfd_hash_entry *gen_entry, if (stub_entry->target_section != data->output_section || stub_entry->stub_type != aarch64_stub_erratum_843419_veneer || stub_entry->adrp_offset != data->adrp_offset) - return TRUE; + return true; /* Change the stub type instead of removing the entry, removing from the hash table would be slower and we have already reserved the memory for the entry @@ -5976,7 +6272,7 @@ _bfd_aarch64_erratum_843419_clear_stub (struct bfd_hash_entry *gen_entry, /* We're done and there could have been only one matching stub at that particular offset, so abort further traversal. */ - return FALSE; + return false; } /* TLS Relaxations may relax an adrp sequence that matches the erratum 843419 @@ -5988,7 +6284,7 @@ static void clear_erratum_843419_entry (struct elf_aarch64_link_hash_table *globals, bfd_vma adrp_offset, asection *input_section) { - if (globals->fix_erratum_843419) + if (globals->fix_erratum_843419 & ERRAT_ADRP) { struct erratum_843419_branch_to_stub_clear_data data; data.adrp_offset = adrp_offset; @@ -6013,7 +6309,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals, bfd_byte *contents, Elf_Internal_Rela *rel, struct elf_link_hash_entry *h) { - bfd_boolean is_local = h == NULL; + bool is_local = h == NULL; unsigned int r_type = ELFNN_R_TYPE (rel->r_info); unsigned long insn; @@ -6401,7 +6697,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals, /* Relocate an AArch64 ELF section. */ -static bfd_boolean +static int elfNN_aarch64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd, @@ -6417,7 +6713,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, Elf_Internal_Rela *relend; const char *name; struct elf_aarch64_link_hash_table *globals; - bfd_boolean save_addend = FALSE; + bool save_addend = false; bfd_vma addend = 0; globals = elf_aarch64_hash_table (info); @@ -6441,7 +6737,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, bfd_reloc_status_type r; arelent bfd_reloc; char sym_type; - bfd_boolean unresolved_reloc = FALSE; + bool unresolved_reloc = false; char *error_message = NULL; r_symndx = ELFNN_R_SYM (rel->r_info); @@ -6474,7 +6770,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, (*info->callbacks->undefined_symbol) (info, bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, sym->st_name), - input_bfd, input_section, rel->r_offset, TRUE); + input_bfd, input_section, rel->r_offset, true); relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); @@ -6483,7 +6779,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) { h = elfNN_aarch64_get_local_sym_hash (globals, input_bfd, - rel, FALSE); + rel, false); if (h == NULL) abort (); @@ -6494,7 +6790,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, } else { - bfd_boolean warned, ignored; + bool warned, ignored; RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, r_symndx, symtab_hdr, sym_hashes, @@ -6518,7 +6814,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, name = (bfd_elf_string_from_elf_section (input_bfd, symtab_hdr->sh_link, sym->st_name)); if (name == NULL || *name == '\0') - name = bfd_section_name (input_bfd, sec); + name = bfd_section_name (sec); } if (r_symndx != 0 @@ -6566,9 +6862,9 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, && rel->r_offset == rel[1].r_offset && ELFNN_R_TYPE (rel[1].r_info) != R_AARCH64_NONE && ELFNN_R_TYPE (rel[1].r_info) != R_AARCH64_NULL) - save_addend = TRUE; + save_addend = true; else - save_addend = FALSE; + save_addend = false; if (r == bfd_reloc_continue) r = elfNN_aarch64_final_link_relocate (howto, input_bfd, output_bfd, @@ -6589,7 +6885,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21: if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx)) { - bfd_boolean need_relocs = FALSE; + bool need_relocs = false; bfd_byte *loc; int indx; bfd_vma off; @@ -6683,7 +6979,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1: if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx)) { - bfd_boolean need_relocs = FALSE; + bool need_relocs = false; bfd_byte *loc; int indx; bfd_vma off; @@ -6739,7 +7035,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, case BFD_RELOC_AARCH64_TLSDESC_OFF_G1: if (! symbol_tlsdesc_got_offset_mark_p (input_bfd, h, r_symndx)) { - bfd_boolean need_relocs = FALSE; + bool need_relocs = false; int indx = h && h->dynindx != -1 ? h->dynindx : 0; bfd_vma off = symbol_tlsdesc_got_offset (input_bfd, h, r_symndx); @@ -6809,7 +7105,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, "unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, (uint64_t) rel->r_offset, howto->name, h->root.root.string); - return FALSE; + return false; } if (r != bfd_reloc_ok && r != bfd_reloc_continue) @@ -6831,7 +7127,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, _("too many GOT entries for -fpic, " "please recompile with -fPIC"), name, input_bfd, input_section, rel->r_offset); - return FALSE; + return false; } /* Overflow can occur when a variable is referenced with a type that has a larger alignment than the type with which it was @@ -6846,7 +7142,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, Try to catch this situation here and provide a more helpful error message to the user. */ - if (addend & ((1 << howto->rightshift) - 1) + if (addend & (((bfd_vma) 1 << howto->rightshift) - 1) /* FIXME: Are we testing all of the appropriate reloc types here ? */ && (real_r_type == BFD_RELOC_AARCH64_LD_LO19_PCREL @@ -6865,7 +7161,7 @@ alignment than was declared where it was defined"), case bfd_reloc_undefined: (*info->callbacks->undefined_symbol) - (info, name, input_bfd, input_section, rel->r_offset, TRUE); + (info, name, input_bfd, input_section, rel->r_offset, true); break; case bfd_reloc_outofrange: @@ -6896,12 +7192,12 @@ alignment than was declared where it was defined"), addend = 0; } - return TRUE; + return true; } /* Set the right machine number. */ -static bfd_boolean +static bool elfNN_aarch64_object_p (bfd *abfd) { #if ARCH_SIZE == 32 @@ -6909,12 +7205,12 @@ elfNN_aarch64_object_p (bfd *abfd) #else bfd_default_set_arch_mach (abfd, bfd_arch_aarch64, bfd_mach_aarch64); #endif - return TRUE; + return true; } /* Function to keep AArch64 specific flags in the ELF header. */ -static bfd_boolean +static bool elfNN_aarch64_set_private_flags (bfd *abfd, flagword flags) { if (elf_flags_init (abfd) && elf_elfheader (abfd)->e_flags != flags) @@ -6923,30 +7219,30 @@ elfNN_aarch64_set_private_flags (bfd *abfd, flagword flags) else { elf_elfheader (abfd)->e_flags = flags; - elf_flags_init (abfd) = TRUE; + elf_flags_init (abfd) = true; } - return TRUE; + return true; } /* Merge backend specific data from an object file to the output object file when linking. */ -static bfd_boolean +static bool elfNN_aarch64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { bfd *obfd = info->output_bfd; flagword out_flags; flagword in_flags; - bfd_boolean flags_compatible = TRUE; + bool flags_compatible = true; asection *sec; /* Check if we have the same endianess. */ if (!_bfd_generic_verify_endian_match (ibfd, info)) - return FALSE; + return false; if (!is_aarch64_elf (ibfd) || !is_aarch64_elf (obfd)) - return TRUE; + return true; /* The input BFD must have had its flags initialised. */ /* The following seems bogus to me -- The flags are initialized in @@ -6967,9 +7263,9 @@ elfNN_aarch64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) to the default values. */ if (bfd_get_arch_info (ibfd)->the_default && elf_elfheader (ibfd)->e_flags == 0) - return TRUE; + return true; - elf_flags_init (obfd) = TRUE; + elf_flags_init (obfd) = true; elf_elfheader (obfd)->e_flags = in_flags; if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) @@ -6977,12 +7273,12 @@ elfNN_aarch64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd)); - return TRUE; + return true; } /* Identical flags must be compatible. */ if (in_flags == out_flags) - return TRUE; + return true; /* Check to see if the input BFD actually contains any sections. If not, its flags may not have been initialised either, but it @@ -6996,22 +7292,22 @@ elfNN_aarch64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) in data sections ? */ if (!(ibfd->flags & DYNAMIC)) { - bfd_boolean null_input_bfd = TRUE; - bfd_boolean only_data_sections = TRUE; + bool null_input_bfd = true; + bool only_data_sections = true; for (sec = ibfd->sections; sec != NULL; sec = sec->next) { - if ((bfd_get_section_flags (ibfd, sec) + if ((bfd_section_flags (sec) & (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS)) == (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS)) - only_data_sections = FALSE; + only_data_sections = false; - null_input_bfd = FALSE; + null_input_bfd = false; break; } if (null_input_bfd || only_data_sections) - return TRUE; + return true; } return flags_compatible; @@ -7019,7 +7315,7 @@ elfNN_aarch64_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) /* Display the flags field. */ -static bfd_boolean +static bool elfNN_aarch64_print_private_bfd_data (bfd *abfd, void *ptr) { FILE *file = (FILE *) ptr; @@ -7035,56 +7331,39 @@ elfNN_aarch64_print_private_bfd_data (bfd *abfd, void *ptr) containing valid data. */ /* xgettext:c-format */ - fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags); + fprintf (file, _("private flags = 0x%lx:"), elf_elfheader (abfd)->e_flags); if (flags) - fprintf (file, _("")); + fprintf (file, _(" ")); fputc ('\n', file); - return TRUE; -} - -/* Find dynamic relocs for H that apply to read-only sections. */ - -static asection * -readonly_dynrelocs (struct elf_link_hash_entry *h) -{ - struct elf_dyn_relocs *p; - - for (p = elf_aarch64_hash_entry (h)->dyn_relocs; p != NULL; p = p->next) - { - asection *s = p->sec->output_section; - - if (s != NULL && (s->flags & SEC_READONLY) != 0) - return p->sec; - } - return NULL; + return true; } /* Return true if we need copy relocation against EH. */ -static bfd_boolean +static bool need_copy_relocation_p (struct elf_aarch64_link_hash_entry *eh) { struct elf_dyn_relocs *p; asection *s; - for (p = eh->dyn_relocs; p != NULL; p = p->next) + for (p = eh->root.dyn_relocs; p != NULL; p = p->next) { /* If there is any pc-relative reference, we need to keep copy relocation to avoid propagating the relocation into runtime that current glibc does not support. */ if (p->pc_count) - return TRUE; + return true; s = p->sec->output_section; /* Need copy relocation if it's against read-only section. */ if (s != NULL && (s->flags & SEC_READONLY) != 0) - return TRUE; + return true; } - return FALSE; + return false; } /* Adjust a symbol defined by a dynamic object and referenced by a @@ -7093,7 +7372,7 @@ need_copy_relocation_p (struct elf_aarch64_link_hash_entry *eh) change the definition to something the rest of the link can understand. */ -static bfd_boolean +static bool elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info, struct elf_link_hash_entry *h) { @@ -7120,7 +7399,7 @@ elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_plt = 0; } - return TRUE; + return true; } else /* Otherwise, reset to -1. */ @@ -7138,7 +7417,7 @@ elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info, h->root.u.def.value = def->root.u.def.value; if (ELIMINATE_COPY_RELOCS || info->nocopyreloc) h->non_got_ref = def->non_got_ref; - return TRUE; + return true; } /* If we are creating a shared library, we must presume that the @@ -7146,18 +7425,18 @@ elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info, For such cases we need not do anything here; the relocations will be handled correctly by relocate_section. */ if (bfd_link_pic (info)) - return TRUE; + return true; /* If there are no references to this symbol that do not use the GOT, we don't need to generate a copy reloc. */ if (!h->non_got_ref) - return TRUE; + return true; /* If -z nocopyreloc was given, we won't generate them either. */ if (info->nocopyreloc) { h->non_got_ref = 0; - return TRUE; + return true; } if (ELIMINATE_COPY_RELOCS) @@ -7169,7 +7448,7 @@ elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info, if (!need_copy_relocation_p (eh)) { h->non_got_ref = 0; - return TRUE; + return true; } } @@ -7208,7 +7487,7 @@ elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info, } -static bfd_boolean +static bool elfNN_aarch64_allocate_local_symbols (bfd *abfd, unsigned number) { struct elf_aarch64_local_symbol *locals; @@ -7218,15 +7497,15 @@ elfNN_aarch64_allocate_local_symbols (bfd *abfd, unsigned number) locals = (struct elf_aarch64_local_symbol *) bfd_zalloc (abfd, number * sizeof (struct elf_aarch64_local_symbol)); if (locals == NULL) - return FALSE; + return false; elf_aarch64_locals (abfd) = locals; } - return TRUE; + return true; } /* Create the .got section to hold the global offset table. */ -static bfd_boolean +static bool aarch64_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) { const struct elf_backend_data *bed = get_elf_backend_data (abfd); @@ -7237,7 +7516,7 @@ aarch64_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) /* This function may be called more than once. */ if (htab->sgot != NULL) - return TRUE; + return true; flags = bed->dynamic_sec_flags; @@ -7247,14 +7526,14 @@ aarch64_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) (bed->dynamic_sec_flags | SEC_READONLY)); if (s == NULL - || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) - return FALSE; + || !bfd_set_section_alignment (s, bed->s->log_file_align)) + return false; htab->srelgot = s; s = bfd_make_section_anyway_with_flags (abfd, ".got", flags); if (s == NULL - || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) - return FALSE; + || !bfd_set_section_alignment (s, bed->s->log_file_align)) + return false; htab->sgot = s; htab->sgot->size += GOT_ENTRY_SIZE; @@ -7268,28 +7547,27 @@ aarch64_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) "_GLOBAL_OFFSET_TABLE_"); elf_hash_table (info)->hgot = h; if (h == NULL) - return FALSE; + return false; } if (bed->want_got_plt) { s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags); if (s == NULL - || !bfd_set_section_alignment (abfd, s, - bed->s->log_file_align)) - return FALSE; + || !bfd_set_section_alignment (s, bed->s->log_file_align)) + return false; htab->sgotplt = s; } /* The first bit of the global offset table is the header. */ s->size += bed->got_header_size; - return TRUE; + return true; } /* Look through the relocs for a section during the first phase. */ -static bfd_boolean +static bool elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, const Elf_Internal_Rela *relocs) { @@ -7302,7 +7580,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, struct elf_aarch64_link_hash_table *htab; if (bfd_link_relocatable (info)) - return TRUE; + return true; BFD_ASSERT (is_aarch64_elf (abfd)); @@ -7328,24 +7606,24 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, { /* xgettext:c-format */ _bfd_error_handler (_("%pB: bad symbol index: %d"), abfd, r_symndx); - return FALSE; + return false; } if (r_symndx < symtab_hdr->sh_info) { /* A local symbol. */ - isym = bfd_sym_from_r_symndx (&htab->sym_cache, + isym = bfd_sym_from_r_symndx (&htab->root.sym_cache, abfd, r_symndx); if (isym == NULL) - return FALSE; + return false; /* Check relocation against local STT_GNU_IFUNC symbol. */ if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC) { h = elfNN_aarch64_get_local_sym_hash (htab, abfd, rel, - TRUE); + true); if (h == NULL) - return FALSE; + return false; /* Fake a STT_GNU_IFUNC symbol. */ h->type = STT_GNU_IFUNC; @@ -7381,7 +7659,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, htab->root.dynobj = abfd; if (! aarch64_elf_create_got_section (htab->root.dynobj, info)) - return FALSE; + return false; BFD_ASSERT (h == htab->root.hgot); } @@ -7412,7 +7690,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, if (htab->root.dynobj == NULL) htab->root.dynobj = abfd; if (!_bfd_elf_create_ifunc_sections (htab->root.dynobj, info)) - return FALSE; + return false; break; } @@ -7446,7 +7724,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, abfd, elfNN_aarch64_howto_table[howto_index].name, (h) ? h->root.root.string : "a local symbol"); bfd_set_error (bfd_error_bad_value); - return FALSE; + return false; } else break; @@ -7465,7 +7743,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, abfd, elfNN_aarch64_howto_table[howto_index].name, (h) ? h->root.root.string : "a local symbol"); bfd_set_error (bfd_error_bad_value); - return FALSE; + return false; } /* Fall through. */ @@ -7540,19 +7818,17 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, htab->root.dynobj = abfd; sreloc = _bfd_elf_make_dynamic_reloc_section - (sec, htab->root.dynobj, LOG_FILE_ALIGN, abfd, /*rela? */ TRUE); + (sec, htab->root.dynobj, LOG_FILE_ALIGN, abfd, /*rela? */ true); if (sreloc == NULL) - return FALSE; + return false; } /* If this is a global symbol, we count the number of relocations we need for this symbol. */ if (h != NULL) { - struct elf_aarch64_link_hash_entry *eh; - eh = (struct elf_aarch64_link_hash_entry *) h; - head = &eh->dyn_relocs; + head = &h->dyn_relocs; } else { @@ -7563,10 +7839,10 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *s; void **vpp; - isym = bfd_sym_from_r_symndx (&htab->sym_cache, + isym = bfd_sym_from_r_symndx (&htab->root.sym_cache, abfd, r_symndx); if (isym == NULL) - return FALSE; + return false; s = bfd_section_from_elf_index (abfd, isym->st_shndx); if (s == NULL) @@ -7581,11 +7857,11 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, p = *head; if (p == NULL || p->sec != sec) { - bfd_size_type amt = sizeof *p; + size_t amt = sizeof *p; p = ((struct elf_dyn_relocs *) bfd_zalloc (htab->root.dynobj, amt)); if (p == NULL) - return FALSE; + return false; p->next = *head; *head = p; p->sec = sec; @@ -7648,7 +7924,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, if (!elfNN_aarch64_allocate_local_symbols (abfd, symtab_hdr->sh_info)) - return FALSE; + return false; locals = elf_aarch64_locals (abfd); BFD_ASSERT (r_symndx < symtab_hdr->sh_info); @@ -7691,7 +7967,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, if (htab->root.dynobj == NULL) htab->root.dynobj = abfd; if (! aarch64_elf_create_got_section (htab->root.dynobj, info)) - return FALSE; + return false; break; } @@ -7714,12 +7990,12 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, } } - return TRUE; + return true; } /* Treat mapping symbols as special target symbols. */ -static bfd_boolean +static bool elfNN_aarch64_is_target_special_symbol (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym) { @@ -7727,125 +8003,60 @@ elfNN_aarch64_is_target_special_symbol (bfd *abfd ATTRIBUTE_UNUSED, BFD_AARCH64_SPECIAL_SYM_TYPE_ANY); } -/* This is a copy of elf_find_function () from elf.c except that - AArch64 mapping symbols are ignored when looking for function names. */ +/* If the ELF symbol SYM might be a function in SEC, return the + function size and set *CODE_OFF to the function's entry point, + otherwise return zero. */ -static bfd_boolean -aarch64_elf_find_function (bfd *abfd ATTRIBUTE_UNUSED, - asymbol **symbols, - asection *section, - bfd_vma offset, - const char **filename_ptr, - const char **functionname_ptr) +static bfd_size_type +elfNN_aarch64_maybe_function_sym (const asymbol *sym, asection *sec, + bfd_vma *code_off) { - const char *filename = NULL; - asymbol *func = NULL; - bfd_vma low_func = 0; - asymbol **p; + bfd_size_type size; + elf_symbol_type * elf_sym = (elf_symbol_type *) sym; - for (p = symbols; *p != NULL; p++) - { - elf_symbol_type *q; - - q = (elf_symbol_type *) * p; + if ((sym->flags & (BSF_SECTION_SYM | BSF_FILE | BSF_OBJECT + | BSF_THREAD_LOCAL | BSF_RELC | BSF_SRELC)) != 0 + || sym->section != sec) + return 0; - switch (ELF_ST_TYPE (q->internal_elf_sym.st_info)) - { - default: - break; - case STT_FILE: - filename = bfd_asymbol_name (&q->symbol); - break; - case STT_FUNC: + size = (sym->flags & BSF_SYNTHETIC) ? 0 : elf_sym->internal_elf_sym.st_size; + + if (!(sym->flags & BSF_SYNTHETIC)) + switch (ELF_ST_TYPE (elf_sym->internal_elf_sym.st_info)) + { case STT_NOTYPE: - /* Skip mapping symbols. */ - if ((q->symbol.flags & BSF_LOCAL) - && (bfd_is_aarch64_special_symbol_name - (q->symbol.name, BFD_AARCH64_SPECIAL_SYM_TYPE_ANY))) - continue; + /* Ignore symbols created by the annobin plugin for gcc and clang. + These symbols are hidden, local, notype and have a size of 0. */ + if (size == 0 + && sym->flags & BSF_LOCAL + && ELF_ST_VISIBILITY (elf_sym->internal_elf_sym.st_other) == STV_HIDDEN) + return 0; /* Fall through. */ - if (bfd_get_section (&q->symbol) == section - && q->symbol.value >= low_func && q->symbol.value <= offset) - { - func = (asymbol *) q; - low_func = q->symbol.value; - } + case STT_FUNC: + /* FIXME: Allow STT_GNU_IFUNC as well ? */ break; - } - } - - if (func == NULL) - return FALSE; - - if (filename_ptr) - *filename_ptr = filename; - if (functionname_ptr) - *functionname_ptr = bfd_asymbol_name (func); - - return TRUE; -} - - -/* Find the nearest line to a particular section and offset, for error - reporting. This code is a duplicate of the code in elf.c, except - that it uses aarch64_elf_find_function. */ - -static bfd_boolean -elfNN_aarch64_find_nearest_line (bfd *abfd, - asymbol **symbols, - asection *section, - bfd_vma offset, - const char **filename_ptr, - const char **functionname_ptr, - unsigned int *line_ptr, - unsigned int *discriminator_ptr) -{ - bfd_boolean found = FALSE; - - if (_bfd_dwarf2_find_nearest_line (abfd, symbols, NULL, section, offset, - filename_ptr, functionname_ptr, - line_ptr, discriminator_ptr, - dwarf_debug_sections, 0, - &elf_tdata (abfd)->dwarf2_find_line_info)) - { - if (!*functionname_ptr) - aarch64_elf_find_function (abfd, symbols, section, offset, - *filename_ptr ? NULL : filename_ptr, - functionname_ptr); - - return TRUE; - } - - /* Skip _bfd_dwarf1_find_nearest_line since no known AArch64 - toolchain uses DWARF1. */ - - if (!_bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, - &found, filename_ptr, - functionname_ptr, line_ptr, - &elf_tdata (abfd)->line_info)) - return FALSE; - - if (found && (*functionname_ptr || *line_ptr)) - return TRUE; - - if (symbols == NULL) - return FALSE; + default: + return 0; + } + + if ((sym->flags & BSF_LOCAL) + && bfd_is_aarch64_special_symbol_name (sym->name, + BFD_AARCH64_SPECIAL_SYM_TYPE_ANY)) + return 0; - if (!aarch64_elf_find_function (abfd, symbols, section, offset, - filename_ptr, functionname_ptr)) - return FALSE; + *code_off = sym->value; - *line_ptr = 0; - return TRUE; + /* Do not return 0 for the function's size. */ + return size ? size : 1; } -static bfd_boolean +static bool elfNN_aarch64_find_inliner_info (bfd *abfd, const char **filename_ptr, const char **functionname_ptr, unsigned int *line_ptr) { - bfd_boolean found; + bool found; found = _bfd_dwarf2_find_inliner_info (abfd, filename_ptr, functionname_ptr, line_ptr, &elf_tdata (abfd)->dwarf2_find_line_info); @@ -7853,16 +8064,17 @@ elfNN_aarch64_find_inliner_info (bfd *abfd, } -static void -elfNN_aarch64_post_process_headers (bfd *abfd, - struct bfd_link_info *link_info) +static bool +elfNN_aarch64_init_file_header (bfd *abfd, struct bfd_link_info *link_info) { Elf_Internal_Ehdr *i_ehdrp; /* ELF file header, internal form. */ + if (!_bfd_elf_init_file_header (abfd, link_info)) + return false; + i_ehdrp = elf_elfheader (abfd); i_ehdrp->e_ident[EI_ABIVERSION] = AARCH64_ELF_ABI_VERSION; - - _bfd_elf_post_process_headers (abfd, link_info); + return true; } static enum elf_reloc_type_class @@ -7918,7 +8130,7 @@ elfNN_aarch64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE called when bfd_section_from_shdr finds a section with an unknown type. */ -static bfd_boolean +static bool elfNN_aarch64_section_from_shdr (bfd *abfd, Elf_Internal_Shdr *hdr, const char *name, int shindex) @@ -7934,13 +8146,13 @@ elfNN_aarch64_section_from_shdr (bfd *abfd, break; default: - return FALSE; + return false; } if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) - return FALSE; + return false; - return TRUE; + return true; } /* A structure used to record a list of sections, independently @@ -8051,7 +8263,7 @@ enum map_symbol_type /* Output a single mapping symbol. */ -static bfd_boolean +static bool elfNN_aarch64_output_map_sym (output_arch_syminfo *osi, enum map_symbol_type type, bfd_vma offset) { @@ -8069,7 +8281,7 @@ elfNN_aarch64_output_map_sym (output_arch_syminfo *osi, /* Output a single local symbol for a generated stub. */ -static bfd_boolean +static bool elfNN_aarch64_output_stub_sym (output_arch_syminfo *osi, const char *name, bfd_vma offset, bfd_vma size) { @@ -8084,7 +8296,7 @@ elfNN_aarch64_output_stub_sym (output_arch_syminfo *osi, const char *name, return osi->func (osi->finfo, name, &sym, osi->sec, NULL) == 1; } -static bfd_boolean +static bool aarch64_map_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) { struct elf_aarch64_stub_hash_entry *stub_entry; @@ -8102,7 +8314,7 @@ aarch64_map_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) /* Ensure this stub is attached to the current section being processed. */ if (stub_sec != osi->sec) - return TRUE; + return true; addr = (bfd_vma) stub_entry->stub_offset; @@ -8113,32 +8325,32 @@ aarch64_map_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) case aarch64_stub_adrp_branch: if (!elfNN_aarch64_output_stub_sym (osi, stub_name, addr, sizeof (aarch64_adrp_branch_stub))) - return FALSE; + return false; if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_INSN, addr)) - return FALSE; + return false; break; case aarch64_stub_long_branch: if (!elfNN_aarch64_output_stub_sym (osi, stub_name, addr, sizeof (aarch64_long_branch_stub))) - return FALSE; + return false; if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_INSN, addr)) - return FALSE; + return false; if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_DATA, addr + 16)) - return FALSE; + return false; break; case aarch64_stub_erratum_835769_veneer: if (!elfNN_aarch64_output_stub_sym (osi, stub_name, addr, sizeof (aarch64_erratum_835769_stub))) - return FALSE; + return false; if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_INSN, addr)) - return FALSE; + return false; break; case aarch64_stub_erratum_843419_veneer: if (!elfNN_aarch64_output_stub_sym (osi, stub_name, addr, sizeof (aarch64_erratum_843419_stub))) - return FALSE; + return false; if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_INSN, addr)) - return FALSE; + return false; break; case aarch64_stub_none: break; @@ -8147,12 +8359,12 @@ aarch64_map_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg) abort (); } - return TRUE; + return true; } /* Output mapping symbols for linker generated sections. */ -static bfd_boolean +static bool elfNN_aarch64_output_arch_local_syms (bfd *output_bfd, struct bfd_link_info *info, void *finfo, @@ -8190,7 +8402,7 @@ elfNN_aarch64_output_arch_local_syms (bfd *output_bfd, /* The first instruction in a stub is always a branch. */ if (!elfNN_aarch64_output_map_sym (&osi, AARCH64_MAP_INSN, 0)) - return FALSE; + return false; bfd_hash_traverse (&htab->stub_hash_table, aarch64_map_one_stub, &osi); @@ -8199,7 +8411,7 @@ elfNN_aarch64_output_arch_local_syms (bfd *output_bfd, /* Finally, output mapping symbols for the PLT. */ if (!htab->root.splt || htab->root.splt->size == 0) - return TRUE; + return true; osi.sec_shndx = _bfd_elf_section_from_bfd_section (output_bfd, htab->root.splt->output_section); @@ -8207,23 +8419,23 @@ elfNN_aarch64_output_arch_local_syms (bfd *output_bfd, elfNN_aarch64_output_map_sym (&osi, AARCH64_MAP_INSN, 0); - return TRUE; + return true; } /* Allocate target specific section data. */ -static bfd_boolean +static bool elfNN_aarch64_new_section_hook (bfd *abfd, asection *sec) { if (!sec->used_by_bfd) { _aarch64_elf_section_data *sdata; - bfd_size_type amt = sizeof (*sdata); + size_t amt = sizeof (*sdata); sdata = bfd_zalloc (abfd, amt); if (sdata == NULL) - return FALSE; + return false; sec->used_by_bfd = sdata; } @@ -8241,7 +8453,7 @@ unrecord_section_via_map_over_sections (bfd *abfd ATTRIBUTE_UNUSED, unrecord_section_with_aarch64_elf_section_data (sec); } -static bfd_boolean +static bool elfNN_aarch64_close_and_cleanup (bfd *abfd) { if (abfd->sections) @@ -8251,7 +8463,7 @@ elfNN_aarch64_close_and_cleanup (bfd *abfd) return _bfd_elf_close_and_cleanup (abfd); } -static bfd_boolean +static bool elfNN_aarch64_bfd_free_cached_info (bfd *abfd) { if (abfd->sections) @@ -8265,13 +8477,13 @@ elfNN_aarch64_bfd_free_cached_info (bfd *abfd) the got, plt, gotplt and their relocation sections are all created in the standard part of the bfd elf backend. */ -static bfd_boolean +static bool elfNN_aarch64_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) { /* We need to create .got section. */ if (!aarch64_elf_create_got_section (dynobj, info)) - return FALSE; + return false; return _bfd_elf_create_dynamic_sections (dynobj, info); } @@ -8280,7 +8492,7 @@ elfNN_aarch64_create_dynamic_sections (bfd *dynobj, /* Allocate space in .plt, .got and associated reloc sections for dynamic relocs. */ -static bfd_boolean +static bool elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) { struct bfd_link_info *info; @@ -8298,7 +8510,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) called to copy all relevant data from the generic to the concrete symbol instance. */ if (h->root.type == bfd_link_hash_indirect) - return TRUE; + return true; if (h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; @@ -8310,7 +8522,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) here if it is defined and referenced in a non-shared object. */ if (h->type == STT_GNU_IFUNC && h->def_regular) - return TRUE; + return true; else if (htab->root.dynamic_sections_created && h->plt.refcount > 0) { /* Make sure this symbol is output as a dynamic symbol. @@ -8319,7 +8531,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) && h->root.type == bfd_link_hash_undefweak) { if (!bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; + return false; } if (bfd_link_pic (info) || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) @@ -8347,7 +8559,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* Make room for this entry. For now we only create the small model PLT entries. We later need to find a way of relaxing into these from the large model PLT entries. */ - s->size += PLT_SMALL_ENTRY_SIZE; + s->size += htab->plt_entry_size; /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ @@ -8370,6 +8582,12 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) updated. */ htab->root.srelplt->reloc_count++; + + /* Mark the DSO in case R__JUMP_SLOT relocs against + variant PCS symbols are present. */ + if (h->other & STO_AARCH64_VARIANT_PCS) + htab->variant_pcs = 1; + } else { @@ -8388,7 +8606,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (h->got.refcount > 0) { - bfd_boolean dyn; + bool dyn; unsigned got_type = elf_aarch64_hash_entry (h)->got_type; h->got.offset = (bfd_vma) - 1; @@ -8401,7 +8619,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) && h->root.type == bfd_link_hash_undefweak) { if (!bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; + return false; } if (got_type == GOT_UNKNOWN) @@ -8461,7 +8679,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) type. */ /* TLSDESC PLT is now needed, but not yet determined. */ - htab->tlsdesc_plt = (bfd_vma) - 1; + htab->root.tlsdesc_plt = (bfd_vma) - 1; } if (got_type & GOT_TLS_GD) @@ -8477,8 +8695,8 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) h->got.offset = (bfd_vma) - 1; } - if (eh->dyn_relocs == NULL) - return TRUE; + if (h->dyn_relocs == NULL) + return true; /* In the shared -Bsymbolic case, discard space allocated for dynamic pc-relative relocs against symbols which turn out to be @@ -8498,7 +8716,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) { struct elf_dyn_relocs **pp; - for (pp = &eh->dyn_relocs; (p = *pp) != NULL;) + for (pp = &h->dyn_relocs; (p = *pp) != NULL;) { p->count -= p->pc_count; p->pc_count = 0; @@ -8511,11 +8729,11 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* Also discard relocs on undefined weak syms with non-default visibility. */ - if (eh->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak) + if (h->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak) { if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)) - eh->dyn_relocs = NULL; + h->dyn_relocs = NULL; /* Make sure undefined weak symbols are output as a dynamic symbol in PIEs. */ @@ -8523,7 +8741,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) && !h->forced_local && h->root.type == bfd_link_hash_undefweak && !bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; + return false; } } @@ -8546,7 +8764,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) && !h->forced_local && h->root.type == bfd_link_hash_undefweak && !bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; + return false; /* If that succeeded, we know we'll be keeping all the relocs. */ @@ -8554,13 +8772,13 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) goto keep; } - eh->dyn_relocs = NULL; + h->dyn_relocs = NULL; keep:; } /* Finally, allocate space. */ - for (p = eh->dyn_relocs; p != NULL; p = p->next) + for (p = h->dyn_relocs; p != NULL; p = p->next) { asection *sreloc; @@ -8571,19 +8789,18 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) sreloc->size += p->count * RELOC_SIZE (htab); } - return TRUE; + return true; } /* Allocate space in .plt, .got and associated reloc sections for ifunc dynamic relocs. */ -static bfd_boolean +static bool elfNN_aarch64_allocate_ifunc_dynrelocs (struct elf_link_hash_entry *h, void *inf) { struct bfd_link_info *info; struct elf_aarch64_link_hash_table *htab; - struct elf_aarch64_link_hash_entry *eh; /* An example of a bfd_link_hash_indirect symbol is versioned symbol. For example: __gxx_personality_v0(bfd_link_hash_indirect) @@ -8595,7 +8812,7 @@ elfNN_aarch64_allocate_ifunc_dynrelocs (struct elf_link_hash_entry *h, called to copy all relevant data from the generic to the concrete symbol instance. */ if (h->root.type == bfd_link_hash_indirect) - return TRUE; + return true; if (h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; @@ -8603,45 +8820,23 @@ elfNN_aarch64_allocate_ifunc_dynrelocs (struct elf_link_hash_entry *h, info = (struct bfd_link_info *) inf; htab = elf_aarch64_hash_table (info); - eh = (struct elf_aarch64_link_hash_entry *) h; - /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it here if it is defined and referenced in a non-shared object. */ if (h->type == STT_GNU_IFUNC && h->def_regular) return _bfd_elf_allocate_ifunc_dyn_relocs (info, h, - &eh->dyn_relocs, - NULL, + &h->dyn_relocs, htab->plt_entry_size, htab->plt_header_size, GOT_ENTRY_SIZE, - FALSE); - return TRUE; -} - -/* Allocate space in .plt, .got and associated reloc sections for - local dynamic relocs. */ - -static bfd_boolean -elfNN_aarch64_allocate_local_dynrelocs (void **slot, void *inf) -{ - struct elf_link_hash_entry *h - = (struct elf_link_hash_entry *) *slot; - - if (h->type != STT_GNU_IFUNC - || !h->def_regular - || !h->ref_regular - || !h->forced_local - || h->root.type != bfd_link_hash_defined) - abort (); - - return elfNN_aarch64_allocate_dynrelocs (h, inf); + false); + return true; } /* Allocate space in .plt, .got and associated reloc sections for local ifunc dynamic relocs. */ -static bfd_boolean +static int elfNN_aarch64_allocate_local_ifunc_dynrelocs (void **slot, void *inf) { struct elf_link_hash_entry *h @@ -8657,44 +8852,17 @@ elfNN_aarch64_allocate_local_ifunc_dynrelocs (void **slot, void *inf) return elfNN_aarch64_allocate_ifunc_dynrelocs (h, inf); } -/* Set DF_TEXTREL if we find any dynamic relocs that apply to - read-only sections. */ - -static bfd_boolean -maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p) -{ - asection *sec; - - if (h->root.type == bfd_link_hash_indirect) - return TRUE; - - sec = readonly_dynrelocs (h); - if (sec != NULL) - { - struct bfd_link_info *info = (struct bfd_link_info *) info_p; - - info->flags |= DF_TEXTREL; - info->callbacks->minfo - (_("%pB: dynamic relocation against `%pT' in read-only section `%pA'\n"), - sec->owner, h->root.root.string, sec); - - /* Not an error, just cut short the traversal. */ - return FALSE; - } - return TRUE; -} - /* This is the most important function of all . Innocuosly named though ! */ -static bfd_boolean +static bool elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) { struct elf_aarch64_link_hash_table *htab; bfd *dynobj; asection *s; - bfd_boolean relocs; + bool relocs; bfd *ibfd; htab = elf_aarch64_hash_table ((info)); @@ -8796,7 +8964,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, { htab->root.srelplt->size += RELOC_SIZE (htab); /* Note RELOC_COUNT not incremented here! */ - htab->tlsdesc_plt = (bfd_vma) - 1; + htab->root.tlsdesc_plt = (bfd_vma) - 1; } if (got_type & GOT_TLS_GD) @@ -8825,11 +8993,6 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, elf_link_hash_traverse (&htab->root, elfNN_aarch64_allocate_ifunc_dynrelocs, info); - /* Allocate .plt and .got entries, and space for local symbols. */ - htab_traverse (htab->loc_hash_table, - elfNN_aarch64_allocate_local_dynrelocs, - info); - /* Allocate .plt and .got entries, and space for local ifunc symbols. */ htab_traverse (htab->loc_hash_table, elfNN_aarch64_allocate_local_ifunc_dynrelocs, @@ -8844,19 +9007,21 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab->root.srelplt) htab->sgotplt_jump_table_size = aarch64_compute_jump_table_size (htab); - if (htab->tlsdesc_plt) + if (htab->root.tlsdesc_plt) { if (htab->root.splt->size == 0) - htab->root.splt->size += PLT_ENTRY_SIZE; - - htab->tlsdesc_plt = htab->root.splt->size; - htab->root.splt->size += PLT_TLSDESC_ENTRY_SIZE; + htab->root.splt->size += htab->plt_header_size; /* If we're not using lazy TLS relocations, don't generate the - GOT entry required. */ - if (!(info->flags & DF_BIND_NOW)) + GOT and PLT entry required. */ + if ((info->flags & DF_BIND_NOW)) + htab->root.tlsdesc_plt = 0; + else { - htab->dt_tlsdesc_got = htab->root.sgot->size; + htab->root.tlsdesc_plt = htab->root.splt->size; + htab->root.splt->size += htab->tlsdesc_plt_entry_size; + + htab->root.tlsdesc_got = htab->root.sgot->size; htab->root.sgot->size += GOT_ENTRY_SIZE; } } @@ -8873,7 +9038,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* We now have determined the sizes of the various dynamic sections. Allocate memory for them. */ - relocs = FALSE; + relocs = false; for (s = dynobj->sections; s != NULL; s = s->next) { if ((s->flags & SEC_LINKER_CREATED) == 0) @@ -8890,10 +9055,10 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Strip this section if we don't need it; see the comment below. */ } - else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) + else if (startswith (bfd_section_name (s), ".rela")) { if (s->size != 0 && s != htab->root.srelplt) - relocs = TRUE; + relocs = true; /* We use the reloc_count field as a counter if we need to copy relocs into the output file. */ @@ -8931,7 +9096,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, of garbage. */ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); if (s->contents == NULL) - return FALSE; + return false; } if (htab->root.dynamic_sections_created) @@ -8944,48 +9109,32 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, #define add_dynamic_entry(TAG, VAL) \ _bfd_elf_add_dynamic_entry (info, TAG, VAL) - if (bfd_link_executable (info)) - { - if (!add_dynamic_entry (DT_DEBUG, 0)) - return FALSE; - } + if (!_bfd_elf_add_dynamic_tags (output_bfd, info, relocs)) + return false; if (htab->root.splt->size != 0) { - if (!add_dynamic_entry (DT_PLTGOT, 0) - || !add_dynamic_entry (DT_PLTRELSZ, 0) - || !add_dynamic_entry (DT_PLTREL, DT_RELA) - || !add_dynamic_entry (DT_JMPREL, 0)) - return FALSE; - - if (htab->tlsdesc_plt - && (!add_dynamic_entry (DT_TLSDESC_PLT, 0) - || !add_dynamic_entry (DT_TLSDESC_GOT, 0))) - return FALSE; - } - - if (relocs) - { - if (!add_dynamic_entry (DT_RELA, 0) - || !add_dynamic_entry (DT_RELASZ, 0) - || !add_dynamic_entry (DT_RELAENT, RELOC_SIZE (htab))) - return FALSE; - - /* If any dynamic relocs apply to a read-only section, - then we need a DT_TEXTREL entry. */ - if ((info->flags & DF_TEXTREL) == 0) - elf_link_hash_traverse (&htab->root, maybe_set_textrel, info); - - if ((info->flags & DF_TEXTREL) != 0) - { - if (!add_dynamic_entry (DT_TEXTREL, 0)) - return FALSE; - } + if (htab->variant_pcs + && !add_dynamic_entry (DT_AARCH64_VARIANT_PCS, 0)) + return false; + + if ((elf_aarch64_tdata (output_bfd)->plt_type == PLT_BTI_PAC) + && (!add_dynamic_entry (DT_AARCH64_BTI_PLT, 0) + || !add_dynamic_entry (DT_AARCH64_PAC_PLT, 0))) + return false; + + else if ((elf_aarch64_tdata (output_bfd)->plt_type == PLT_BTI) + && !add_dynamic_entry (DT_AARCH64_BTI_PLT, 0)) + return false; + + else if ((elf_aarch64_tdata (output_bfd)->plt_type == PLT_PAC) + && !add_dynamic_entry (DT_AARCH64_PAC_PLT, 0)) + return false; } } #undef add_dynamic_entry - return TRUE; + return true; } static inline void @@ -9058,7 +9207,13 @@ elfNN_aarch64_create_small_pltn_entry (struct elf_link_hash_entry *h, gotplt->output_offset + got_offset; /* Copy in the boiler-plate for the PLTn entry. */ - memcpy (plt_entry, elfNN_aarch64_small_plt_entry, PLT_SMALL_ENTRY_SIZE); + memcpy (plt_entry, htab->plt_entry, htab->plt_entry_size); + + /* First instruction in BTI enabled PLT stub is a BTI + instruction so skip it. */ + if (elf_aarch64_tdata (output_bfd)->plt_type & PLT_BTI + && elf_elfheader (output_bfd)->e_type == ET_EXEC) + plt_entry = plt_entry + 4; /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8. ADRP: ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */ @@ -9114,14 +9269,14 @@ elfNN_aarch64_create_small_pltn_entry (struct elf_link_hash_entry *h, /* Size sections even though they're not dynamic. We use it to setup _TLS_MODULE_BASE_, if needed. */ -static bfd_boolean +static bool elfNN_aarch64_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) { asection *tls_sec; if (bfd_link_relocatable (info)) - return TRUE; + return true; tls_sec = elf_hash_table (info)->tls_sec; @@ -9130,7 +9285,7 @@ elfNN_aarch64_always_size_sections (bfd *output_bfd, struct elf_link_hash_entry *tlsbase; tlsbase = elf_link_hash_lookup (elf_hash_table (info), - "_TLS_MODULE_BASE_", TRUE, TRUE, FALSE); + "_TLS_MODULE_BASE_", true, true, false); if (tlsbase) { @@ -9140,24 +9295,24 @@ elfNN_aarch64_always_size_sections (bfd *output_bfd, if (!(_bfd_generic_link_add_one_symbol (info, output_bfd, "_TLS_MODULE_BASE_", BSF_LOCAL, - tls_sec, 0, NULL, FALSE, bed->collect, &h))) - return FALSE; + tls_sec, 0, NULL, false, bed->collect, &h))) + return false; tlsbase->type = STT_TLS; tlsbase = (struct elf_link_hash_entry *) h; tlsbase->def_regular = 1; tlsbase->other = STV_HIDDEN; - (*bed->elf_backend_hide_symbol) (info, tlsbase, TRUE); + (*bed->elf_backend_hide_symbol) (info, tlsbase, true); } } - return TRUE; + return true; } /* Finish up dynamic symbol handling. We set the contents of various dynamic sections here. */ -static bfd_boolean +static bool elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, struct elf_link_hash_entry *h, @@ -9197,7 +9352,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, || plt == NULL || gotplt == NULL || relplt == NULL) - return FALSE; + return false; elfNN_aarch64_create_small_pltn_entry (h, htab, output_bfd, info); if (!h->def_regular) @@ -9260,13 +9415,13 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, + h->plt.offset), htab->root.sgot->contents + (h->got.offset & ~(bfd_vma) 1)); - return TRUE; + return true; } } else if (bfd_link_pic (info) && SYMBOL_REFERENCES_LOCAL (info, h)) { if (!(h->def_regular || ELF_COMMON_DEF_P (h))) - return FALSE; + return false; BFD_ASSERT ((h->got.offset & 1) != 0); rela.r_info = ELFNN_R_INFO (0, AARCH64_R (RELATIVE)); @@ -9276,7 +9431,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, } else { -do_glob_dat: + do_glob_dat: BFD_ASSERT ((h->got.offset & 1) == 0); bfd_put_NN (output_bfd, (bfd_vma) 0, htab->root.sgot->contents + h->got.offset); @@ -9322,13 +9477,13 @@ do_glob_dat: || h == elf_hash_table (info)->hgot)) sym->st_shndx = SHN_ABS; - return TRUE; + return true; } /* Finish up local dynamic symbol handling. We set the contents of various dynamic sections here. */ -static bfd_boolean +static int elfNN_aarch64_finish_local_dynamic_symbol (void **slot, void *inf) { struct elf_link_hash_entry *h @@ -9363,10 +9518,13 @@ elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED, bfd_vma plt_base; - memcpy (htab->root.splt->contents, elfNN_aarch64_small_plt0_entry, - PLT_ENTRY_SIZE); - elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize = - PLT_ENTRY_SIZE; + memcpy (htab->root.splt->contents, htab->plt0_entry, + htab->plt_header_size); + + /* PR 26312: Explicitly set the sh_entsize to 0 so that + consumers do not think that the section contains fixed + sized objects. */ + elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize = 0; plt_got_2nd_ent = (htab->root.sgotplt->output_section->vma + htab->root.sgotplt->output_offset @@ -9375,22 +9533,28 @@ elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED, plt_base = htab->root.splt->output_section->vma + htab->root.splt->output_offset; + /* First instruction in BTI enabled PLT stub is a BTI + instruction so skip it. */ + bfd_byte *plt0_entry = htab->root.splt->contents; + if (elf_aarch64_tdata (output_bfd)->plt_type & PLT_BTI) + plt0_entry = plt0_entry + 4; + /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8. ADRP: ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */ elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_ADR_HI21_PCREL, - htab->root.splt->contents + 4, + plt0_entry + 4, PG (plt_got_2nd_ent) - PG (plt_base + 4)); elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_LDSTNN_LO12, - htab->root.splt->contents + 8, + plt0_entry + 8, PG_OFFSET (plt_got_2nd_ent)); elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_ADD_LO12, - htab->root.splt->contents + 12, + plt0_entry + 12, PG_OFFSET (plt_got_2nd_ent)); } -static bfd_boolean +static bool elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) { @@ -9441,13 +9605,14 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, case DT_TLSDESC_PLT: s = htab->root.splt; dyn.d_un.d_ptr = s->output_section->vma + s->output_offset - + htab->tlsdesc_plt; + + htab->root.tlsdesc_plt; break; case DT_TLSDESC_GOT: s = htab->root.sgot; + BFD_ASSERT (htab->root.tlsdesc_got != (bfd_vma)-1); dyn.d_un.d_ptr = s->output_section->vma + s->output_offset - + htab->dt_tlsdesc_got; + + htab->root.tlsdesc_got; break; } @@ -9461,23 +9626,29 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, { elfNN_aarch64_init_small_plt0_entry (output_bfd, htab); - elf_section_data (htab->root.splt->output_section)-> - this_hdr.sh_entsize = htab->plt_entry_size; - - - if (htab->tlsdesc_plt) + if (htab->root.tlsdesc_plt && !(info->flags & DF_BIND_NOW)) { + BFD_ASSERT (htab->root.tlsdesc_got != (bfd_vma)-1); bfd_put_NN (output_bfd, (bfd_vma) 0, - htab->root.sgot->contents + htab->dt_tlsdesc_got); + htab->root.sgot->contents + htab->root.tlsdesc_got); + + const bfd_byte *entry = elfNN_aarch64_tlsdesc_small_plt_entry; + htab->tlsdesc_plt_entry_size = PLT_TLSDESC_ENTRY_SIZE; - memcpy (htab->root.splt->contents + htab->tlsdesc_plt, - elfNN_aarch64_tlsdesc_small_plt_entry, - sizeof (elfNN_aarch64_tlsdesc_small_plt_entry)); + aarch64_plt_type type = elf_aarch64_tdata (output_bfd)->plt_type; + if (type == PLT_BTI || type == PLT_BTI_PAC) + { + entry = elfNN_aarch64_tlsdesc_small_plt_bti_entry; + } + + memcpy (htab->root.splt->contents + htab->root.tlsdesc_plt, + entry, htab->tlsdesc_plt_entry_size); { bfd_vma adrp1_addr = htab->root.splt->output_section->vma - + htab->root.splt->output_offset + htab->tlsdesc_plt + 4; + + htab->root.splt->output_offset + + htab->root.tlsdesc_plt + 4; bfd_vma adrp2_addr = adrp1_addr + 4; @@ -9489,10 +9660,19 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, htab->root.sgotplt->output_section->vma + htab->root.sgotplt->output_offset; - bfd_vma dt_tlsdesc_got = got_addr + htab->dt_tlsdesc_got; + bfd_vma dt_tlsdesc_got = got_addr + htab->root.tlsdesc_got; bfd_byte *plt_entry = - htab->root.splt->contents + htab->tlsdesc_plt; + htab->root.splt->contents + htab->root.tlsdesc_plt; + + /* First instruction in BTI enabled PLT stub is a BTI + instruction so skip it. */ + if (type & PLT_BTI) + { + plt_entry = plt_entry + 4; + adrp1_addr = adrp1_addr + 4; + adrp2_addr = adrp2_addr + 4; + } /* adrp x2, DT_TLSDESC_GOT */ elf_aarch64_update_plt_entry (output_bfd, @@ -9529,7 +9709,7 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, { _bfd_error_handler (_("discarded output section: `%pA'"), htab->root.sgotplt); - return FALSE; + return false; } /* Fill in the first three entries in the global offset table. */ @@ -9569,7 +9749,58 @@ elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd, elfNN_aarch64_finish_local_dynamic_symbol, info); - return TRUE; + return true; +} + +/* Check if BTI enabled PLTs are needed. Returns the type needed. */ +static aarch64_plt_type +get_plt_type (bfd *abfd) +{ + aarch64_plt_type ret = PLT_NORMAL; + bfd_byte *contents, *extdyn, *extdynend; + asection *sec = bfd_get_section_by_name (abfd, ".dynamic"); + if (!sec || !bfd_malloc_and_get_section (abfd, sec, &contents)) + return ret; + extdyn = contents; + extdynend = contents + sec->size; + for (; extdyn < extdynend; extdyn += sizeof (ElfNN_External_Dyn)) + { + Elf_Internal_Dyn dyn; + bfd_elfNN_swap_dyn_in (abfd, extdyn, &dyn); + + /* Let's check the processor specific dynamic array tags. */ + bfd_vma tag = dyn.d_tag; + if (tag < DT_LOPROC || tag > DT_HIPROC) + continue; + + switch (tag) + { + case DT_AARCH64_BTI_PLT: + ret |= PLT_BTI; + break; + + case DT_AARCH64_PAC_PLT: + ret |= PLT_PAC; + break; + + default: break; + } + } + free (contents); + return ret; +} + +static long +elfNN_aarch64_get_synthetic_symtab (bfd *abfd, + long symcount, + asymbol **syms, + long dynsymcount, + asymbol **dynsyms, + asymbol **ret) +{ + elf_aarch64_tdata (abfd)->plt_type = get_plt_type (abfd); + return _bfd_elf_get_synthetic_symtab (abfd, symcount, syms, + dynsymcount, dynsyms, ret); } /* Return address for Ith PLT stub in section PLT, for relocation REL @@ -9579,7 +9810,27 @@ static bfd_vma elfNN_aarch64_plt_sym_val (bfd_vma i, const asection *plt, const arelent *rel ATTRIBUTE_UNUSED) { - return plt->vma + PLT_ENTRY_SIZE + i * PLT_SMALL_ENTRY_SIZE; + size_t plt0_size = PLT_ENTRY_SIZE; + size_t pltn_size = PLT_SMALL_ENTRY_SIZE; + + if (elf_aarch64_tdata (plt->owner)->plt_type == PLT_BTI_PAC) + { + if (elf_elfheader (plt->owner)->e_type == ET_EXEC) + pltn_size = PLT_BTI_PAC_SMALL_ENTRY_SIZE; + else + pltn_size = PLT_PAC_SMALL_ENTRY_SIZE; + } + else if (elf_aarch64_tdata (plt->owner)->plt_type == PLT_BTI) + { + if (elf_elfheader (plt->owner)->e_type == ET_EXEC) + pltn_size = PLT_BTI_SMALL_ENTRY_SIZE; + } + else if (elf_aarch64_tdata (plt->owner)->plt_type == PLT_PAC) + { + pltn_size = PLT_PAC_SMALL_ENTRY_SIZE; + } + + return plt->vma + plt0_size + i * pltn_size; } /* Returns TRUE if NAME is an AArch64 mapping symbol. @@ -9587,7 +9838,7 @@ elfNN_aarch64_plt_sym_val (bfd_vma i, const asection *plt, It also allows a period initiated suffix to be added to the symbol, ie: "$[adtx]\.[:sym_char]+". */ -static bfd_boolean +static bool is_aarch64_mapping_symbol (const char * name) { return name != NULL /* Paranoia. */ @@ -9616,6 +9867,61 @@ elfNN_aarch64_backend_symbol_processing (bfd *abfd, asymbol *sym) sym->flags |= BSF_KEEP; } +/* Implement elf_backend_setup_gnu_properties for AArch64. It serves as a + wrapper function for _bfd_aarch64_elf_link_setup_gnu_properties to account + for the effect of GNU properties of the output_bfd. */ +static bfd * +elfNN_aarch64_link_setup_gnu_properties (struct bfd_link_info *info) +{ + uint32_t prop = elf_aarch64_tdata (info->output_bfd)->gnu_and_prop; + bfd *pbfd = _bfd_aarch64_elf_link_setup_gnu_properties (info, &prop); + elf_aarch64_tdata (info->output_bfd)->gnu_and_prop = prop; + elf_aarch64_tdata (info->output_bfd)->plt_type + |= (prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) ? PLT_BTI : 0; + setup_plt_values (info, elf_aarch64_tdata (info->output_bfd)->plt_type); + return pbfd; +} + +/* Implement elf_backend_merge_gnu_properties for AArch64. It serves as a + wrapper function for _bfd_aarch64_elf_merge_gnu_properties to account + for the effect of GNU properties of the output_bfd. */ +static bool +elfNN_aarch64_merge_gnu_properties (struct bfd_link_info *info, + bfd *abfd, bfd *bbfd, + elf_property *aprop, + elf_property *bprop) +{ + uint32_t prop + = elf_aarch64_tdata (info->output_bfd)->gnu_and_prop; + + /* If output has been marked with BTI using command line argument, give out + warning if necessary. */ + /* Properties are merged per type, hence only check for warnings when merging + GNU_PROPERTY_AARCH64_FEATURE_1_AND. */ + if (((aprop && aprop->pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) + || (bprop && bprop->pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)) + && (prop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) + && (!elf_aarch64_tdata (info->output_bfd)->no_bti_warn)) + { + if ((aprop && !(aprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) + || !aprop) + { + _bfd_error_handler (_("%pB: warning: BTI turned on by -z force-bti when " + "all inputs do not have BTI in NOTE section."), + abfd); + } + if ((bprop && !(bprop->u.number & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) + || !bprop) + { + _bfd_error_handler (_("%pB: warning: BTI turned on by -z force-bti when " + "all inputs do not have BTI in NOTE section."), + bbfd); + } + } + + return _bfd_aarch64_elf_merge_gnu_properties (info, abfd, aprop, + bprop, prop); +} /* We use this so we can override certain functions (though currently we don't). */ @@ -9687,8 +9993,8 @@ const struct elf_size_info elfNN_aarch64_size_info = #define bfd_elfNN_find_inliner_info \ elfNN_aarch64_find_inliner_info -#define bfd_elfNN_find_nearest_line \ - elfNN_aarch64_find_nearest_line +#define bfd_elfNN_get_synthetic_symtab \ + elfNN_aarch64_get_synthetic_symtab #define bfd_elfNN_mkobject \ elfNN_aarch64_mkobject @@ -9708,6 +10014,9 @@ const struct elf_size_info elfNN_aarch64_size_info = #define elf_backend_copy_indirect_symbol \ elfNN_aarch64_copy_indirect_symbol +#define elf_backend_merge_symbol_attribute \ + elfNN_aarch64_merge_symbol_attribute + /* Create .dynbss, and .rela.bss sections in DYNOBJ, and set up shortcuts to them in our hash. */ #define elf_backend_create_dynamic_sections \ @@ -9728,11 +10037,14 @@ const struct elf_size_info elfNN_aarch64_size_info = #define elf_backend_output_arch_local_syms \ elfNN_aarch64_output_arch_local_syms +#define elf_backend_maybe_function_sym \ + elfNN_aarch64_maybe_function_sym + #define elf_backend_plt_sym_val \ elfNN_aarch64_plt_sym_val -#define elf_backend_post_process_headers \ - elfNN_aarch64_post_process_headers +#define elf_backend_init_file_header \ + elfNN_aarch64_init_file_header #define elf_backend_relocate_section \ elfNN_aarch64_relocate_section @@ -9755,6 +10067,12 @@ const struct elf_size_info elfNN_aarch64_size_info = #define elf_backend_symbol_processing \ elfNN_aarch64_backend_symbol_processing +#define elf_backend_setup_gnu_properties \ + elfNN_aarch64_link_setup_gnu_properties + +#define elf_backend_merge_gnu_properties \ + elfNN_aarch64_merge_gnu_properties + #define elf_backend_can_refcount 1 #define elf_backend_can_gc_sections 1 #define elf_backend_plt_readonly 1