X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=bfd%2Felf32-microblaze.c;h=d9c0d93a01a60e2c462a50e1269966760c989360;hb=784712bf4fed9507cb807277ac64d07686bab2c1;hp=29fffb4e2c10bac879f66efd030bde5c02fbed0e;hpb=38f14ab8fcfa4eab8bab417a5a165b7403ef9b0e;p=binutils-gdb.git diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c index 29fffb4e2c1..d9c0d93a01a 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -1,6 +1,6 @@ /* Xilinx MicroBlaze-specific support for 32-bit ELF - Copyright (C) 2009-2018 Free Software Foundation, Inc. + Copyright (C) 2009-2021 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -20,8 +20,6 @@ Boston, MA 02110-1301, USA. */ -int dbg = 0; - #include "sysdep.h" #include "bfd.h" #include "bfdlink.h" @@ -46,373 +44,403 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 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. */ NULL, /* Special Function. */ "R_MICROBLAZE_NONE", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* A standard 32 bit relocation. */ HOWTO (R_MICROBLAZE_32, /* Type. */ 0, /* Rightshift. */ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 32, /* Bitsize. */ - FALSE, /* PC_relative. */ + false, /* PC_relative. */ 0, /* Bitpos. */ complain_overflow_bitfield, /* Complain on overflow. */ bfd_elf_generic_reloc,/* Special Function. */ "R_MICROBLAZE_32", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0xffffffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* A standard PCREL 32 bit relocation. */ HOWTO (R_MICROBLAZE_32_PCREL,/* Type. */ 0, /* Rightshift. */ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 32, /* Bitsize. */ - TRUE, /* PC_relative. */ + true, /* PC_relative. */ 0, /* Bitpos. */ complain_overflow_bitfield, /* Complain on overflow. */ bfd_elf_generic_reloc,/* Special Function. */ "R_MICROBLAZE_32_PCREL", /* Name. */ - TRUE, /* Partial Inplace. */ + true, /* Partial Inplace. */ 0, /* Source Mask. */ 0xffffffff, /* Dest Mask. */ - TRUE), /* PC relative offset? */ + true), /* PC relative offset? */ /* A 64 bit PCREL relocation. Table-entry not really used. */ HOWTO (R_MICROBLAZE_64_PCREL,/* 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. */ "R_MICROBLAZE_64_PCREL", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - TRUE), /* PC relative offset? */ + true), /* PC relative offset? */ /* The low half of a PCREL 32 bit relocation. */ HOWTO (R_MICROBLAZE_32_PCREL_LO, /* Type. */ 0, /* Rightshift. */ 2, /* 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. */ "R_MICROBLAZE_32_PCREL_LO", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - TRUE), /* PC relative offset? */ + true), /* PC relative offset? */ /* A 64 bit relocation. Table entry not really used. */ HOWTO (R_MICROBLAZE_64, /* 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. */ "R_MICROBLAZE_64", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* The low half of a 32 bit relocation. */ HOWTO (R_MICROBLAZE_32_LO, /* Type. */ 0, /* Rightshift. */ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 16, /* Bitsize. */ - FALSE, /* PC_relative. */ + false, /* PC_relative. */ 0, /* Bitpos. */ complain_overflow_signed, /* Complain on overflow. */ bfd_elf_generic_reloc,/* Special Function. */ "R_MICROBLAZE_32_LO", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* Read-only small data section relocation. */ HOWTO (R_MICROBLAZE_SRO32, /* Type. */ 0, /* Rightshift. */ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 16, /* Bitsize. */ - FALSE, /* PC_relative. */ + false, /* PC_relative. */ 0, /* Bitpos. */ complain_overflow_bitfield, /* Complain on overflow. */ bfd_elf_generic_reloc,/* Special Function. */ "R_MICROBLAZE_SRO32", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* Read-write small data area relocation. */ HOWTO (R_MICROBLAZE_SRW32, /* Type. */ 0, /* Rightshift. */ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 16, /* Bitsize. */ - FALSE, /* PC_relative. */ + false, /* PC_relative. */ 0, /* Bitpos. */ complain_overflow_bitfield, /* Complain on overflow. */ bfd_elf_generic_reloc,/* Special Function. */ "R_MICROBLAZE_SRW32", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* This reloc does nothing. Used for relaxation. */ HOWTO (R_MICROBLAZE_64_NONE, /* Type. */ 0, /* Rightshift. */ 3, /* Size (0 = byte, 1 = short, 2 = long). */ 0, /* Bitsize. */ - TRUE, /* PC_relative. */ + true, /* PC_relative. */ 0, /* Bitpos. */ complain_overflow_dont, /* Complain on overflow. */ NULL, /* Special Function. */ "R_MICROBLAZE_64_NONE",/* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* Symbol Op Symbol relocation. */ HOWTO (R_MICROBLAZE_32_SYM_OP_SYM, /* Type. */ 0, /* Rightshift. */ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 32, /* Bitsize. */ - FALSE, /* PC_relative. */ + false, /* PC_relative. */ 0, /* Bitpos. */ complain_overflow_bitfield, /* Complain on overflow. */ bfd_elf_generic_reloc,/* Special Function. */ "R_MICROBLAZE_32_SYM_OP_SYM", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0xffffffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* GNU extension to record C++ vtable hierarchy. */ HOWTO (R_MICROBLAZE_GNU_VTINHERIT, /* 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. */ NULL, /* Special Function. */ "R_MICROBLAZE_GNU_VTINHERIT", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* GNU extension to record C++ vtable member usage. */ HOWTO (R_MICROBLAZE_GNU_VTENTRY, /* 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_rel_vtable_reloc_fn, /* Special Function. */ "R_MICROBLAZE_GNU_VTENTRY", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* A 64 bit GOTPC relocation. Table-entry not really used. */ HOWTO (R_MICROBLAZE_GOTPC_64, /* 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. */ "R_MICROBLAZE_GOTPC_64", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ + 0, /* Source Mask. */ + 0x0000ffff, /* Dest Mask. */ + true), /* PC relative offset? */ + + /* A 64 bit TEXTPCREL relocation. Table-entry not really used. */ + HOWTO (R_MICROBLAZE_TEXTPCREL_64, /* Type. */ + 0, /* Rightshift. */ + 2, /* Size (0 = byte, 1 = short, 2 = long). */ + 16, /* Bitsize. */ + true, /* PC_relative. */ + 0, /* Bitpos. */ + complain_overflow_dont, /* Complain on overflow. */ + bfd_elf_generic_reloc, /* Special Function. */ + "R_MICROBLAZE_TEXTPCREL_64", /* Name. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - TRUE), /* PC relative offset? */ + true), /* PC relative offset? */ /* A 64 bit GOT relocation. Table-entry not really used. */ HOWTO (R_MICROBLAZE_GOT_64, /* 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. */ "R_MICROBLAZE_GOT_64",/* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ + + /* A 64 bit TEXTREL relocation. Table-entry not really used. */ + HOWTO (R_MICROBLAZE_TEXTREL_64, /* Type. */ + 0, /* Rightshift. */ + 2, /* Size (0 = byte, 1 = short, 2 = long). */ + 16, /* Bitsize. */ + false, /* PC_relative. */ + 0, /* Bitpos. */ + complain_overflow_dont, /* Complain on overflow. */ + bfd_elf_generic_reloc,/* Special Function. */ + "R_MICROBLAZE_TEXTREL_64",/* Name. */ + false, /* Partial Inplace. */ + 0, /* Source Mask. */ + 0x0000ffff, /* Dest Mask. */ + false), /* PC relative offset? */ /* A 64 bit PLT relocation. Table-entry not really used. */ HOWTO (R_MICROBLAZE_PLT_64, /* 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. */ "R_MICROBLAZE_PLT_64",/* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - TRUE), /* PC relative offset? */ + true), /* PC relative offset? */ /* Table-entry not really used. */ HOWTO (R_MICROBLAZE_REL, /* 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. */ "R_MICROBLAZE_REL", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - TRUE), /* PC relative offset? */ + true), /* PC relative offset? */ /* Table-entry not really used. */ HOWTO (R_MICROBLAZE_JUMP_SLOT,/* 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. */ "R_MICROBLAZE_JUMP_SLOT", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - TRUE), /* PC relative offset? */ + true), /* PC relative offset? */ /* Table-entry not really used. */ HOWTO (R_MICROBLAZE_GLOB_DAT,/* 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. */ "R_MICROBLAZE_GLOB_DAT", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - TRUE), /* PC relative offset? */ + true), /* PC relative offset? */ /* A 64 bit GOT relative relocation. Table-entry not really used. */ HOWTO (R_MICROBLAZE_GOTOFF_64, /* 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. */ "R_MICROBLAZE_GOTOFF_64", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* A 32 bit GOT relative relocation. Table-entry not really used. */ HOWTO (R_MICROBLAZE_GOTOFF_32, /* 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. */ "R_MICROBLAZE_GOTOFF_32", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* COPY relocation. Table-entry not really used. */ HOWTO (R_MICROBLAZE_COPY, /* 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. */ "R_MICROBLAZE_COPY", /* Name. */ - FALSE, /* Partial Inplace. */ + false, /* Partial Inplace. */ 0, /* Source Mask. */ 0x0000ffff, /* Dest Mask. */ - FALSE), /* PC relative offset? */ + false), /* PC relative offset? */ /* Marker relocs for TLS. */ HOWTO (R_MICROBLAZE_TLS, 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_MICROBLAZE_TLS", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (R_MICROBLAZE_TLSGD, 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_MICROBLAZE_TLSGD", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ HOWTO (R_MICROBLAZE_TLSLD, 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_MICROBLAZE_TLSLD", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Computes the load module index of the load module that contains the definition of its TLS sym. */ @@ -420,15 +448,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_MICROBLAZE_TLSDTPMOD32", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Computes a dtv-relative displacement, the difference between the value of sym+add and the base address of the thread-local storage block that @@ -437,15 +465,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_MICROBLAZE_TLSDTPREL32", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Computes a dtv-relative displacement, the difference between the value of sym+add and the base address of the thread-local storage block that @@ -454,15 +482,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_MICROBLAZE_TLSDTPREL64", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Computes a tp-relative displacement, the difference between the value of sym+add and the value of the thread pointer (r13). */ @@ -470,15 +498,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_MICROBLAZE_TLSGOTTPREL32", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ /* Computes a tp-relative displacement, the difference between the value of sym+add and the value of the thread pointer (r13). */ @@ -486,15 +514,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - FALSE, /* pc_relative */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_MICROBLAZE_TLSTPREL32", /* name */ - FALSE, /* partial_inplace */ + false, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - FALSE), /* pcrel_offset */ + false), /* pcrel_offset */ }; @@ -578,6 +606,12 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, case BFD_RELOC_MICROBLAZE_64_GOT: microblaze_reloc = R_MICROBLAZE_GOT_64; break; + case BFD_RELOC_MICROBLAZE_64_TEXTPCREL: + microblaze_reloc = R_MICROBLAZE_TEXTPCREL_64; + break; + case BFD_RELOC_MICROBLAZE_64_TEXTREL: + microblaze_reloc = R_MICROBLAZE_TEXTREL_64; + break; case BFD_RELOC_MICROBLAZE_64_PLT: microblaze_reloc = R_MICROBLAZE_PLT_64; break; @@ -638,7 +672,7 @@ microblaze_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, /* Set the howto pointer for a RCE ELF reloc. */ -static void +static bool microblaze_elf_info_to_howto (bfd * abfd, arelent * cache_ptr, Elf_Internal_Rela * dst) @@ -656,22 +690,23 @@ microblaze_elf_info_to_howto (bfd * abfd, _bfd_error_handler (_("%pB: unsupported relocation type %#x"), abfd, r_type); bfd_set_error (bfd_error_bad_value); - r_type = R_MICROBLAZE_NONE; + return false; } cache_ptr->howto = microblaze_elf_howto_table [r_type]; + return true; } /* Microblaze ELF local labels start with 'L.' or '$L', not '.L'. */ -static bfd_boolean +static bool microblaze_elf_is_local_label_name (bfd *abfd, const char *name) { if (name[0] == 'L' && name[1] == '.') - return TRUE; + return true; if (name[0] == '$' && name[1] == 'L') - return TRUE; + return true; /* With gcc, the labels go back to starting with '.', so we accept the generic ELF local label syntax as well. */ @@ -684,9 +719,6 @@ struct elf32_mb_link_hash_entry { struct elf_link_hash_entry elf; - /* Track dynamic relocs copied for this symbol. */ - struct elf_dyn_relocs *dyn_relocs; - /* TLS Reference Types for the symbol; Updated by check_relocs */ #define TLS_GD 1 /* GD reloc. */ #define TLS_LD 2 /* LD reloc. */ @@ -710,9 +742,6 @@ struct elf32_mb_link_hash_table { struct elf_link_hash_table elf; - /* Small local sym to section mapping cache. */ - struct sym_cache sym_sec; - /* TLS Local Dynamic GOT Entry */ union { bfd_signed_vma refcount; @@ -725,9 +754,10 @@ struct elf32_mb_link_hash_table /* Get the ELF linker hash table from a link_info structure. */ -#define elf32_mb_hash_table(p) \ - (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \ - == MICROBLAZE_ELF_DATA ? ((struct elf32_mb_link_hash_table *) ((p)->hash)) : NULL) +#define elf32_mb_hash_table(p) \ + ((is_elf_hash_table ((p)->hash) \ + && elf_hash_table_id (elf_hash_table (p)) == MICROBLAZE_ELF_DATA) \ + ? (struct elf32_mb_link_hash_table *) (p)->hash : NULL) /* Create an entry in a microblaze ELF linker hash table. */ @@ -753,7 +783,6 @@ link_hash_newfunc (struct bfd_hash_entry *entry, struct elf32_mb_link_hash_entry *eh; eh = (struct elf32_mb_link_hash_entry *) entry; - eh->dyn_relocs = NULL; eh->tls_mask = 0; } @@ -766,7 +795,7 @@ static struct bfd_link_hash_table * microblaze_elf_link_hash_table_create (bfd *abfd) { struct elf32_mb_link_hash_table *ret; - bfd_size_type amt = sizeof (struct elf32_mb_link_hash_table); + size_t amt = sizeof (struct elf32_mb_link_hash_table); ret = (struct elf32_mb_link_hash_table *) bfd_zmalloc (amt); if (ret == NULL) @@ -790,14 +819,14 @@ microblaze_elf_final_sdp (struct bfd_link_info *info) { struct bfd_link_hash_entry *h; - h = bfd_link_hash_lookup (info->hash, RO_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE); + h = bfd_link_hash_lookup (info->hash, RO_SDA_ANCHOR_NAME, false, false, true); if (h != (struct bfd_link_hash_entry *) NULL && h->type == bfd_link_hash_defined) ro_small_data_pointer = (h->u.def.value + h->u.def.section->output_section->vma + h->u.def.section->output_offset); - h = bfd_link_hash_lookup (info->hash, RW_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE); + h = bfd_link_hash_lookup (info->hash, RW_SDA_ANCHOR_NAME, false, false, true); if (h != (struct bfd_link_hash_entry *) NULL && h->type == bfd_link_hash_defined) rw_small_data_pointer = (h->u.def.value @@ -873,7 +902,7 @@ microblaze_elf_output_dynamic_relocation (bfd *output_bfd, section, which means that the addend must be adjusted accordingly. */ -static bfd_boolean +static int microblaze_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd, @@ -889,7 +918,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, Elf_Internal_Rela *rel, *relend; int endian = (bfd_little_endian (output_bfd)) ? 0 : 2; /* Assume success. */ - bfd_boolean ret = TRUE; + bool ret = true; asection *sreloc; bfd_vma *local_got_offsets; unsigned int tls_type; @@ -899,7 +928,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, htab = elf32_mb_hash_table (info); if (htab == NULL) - return FALSE; + return false; local_got_offsets = elf_local_got_offsets (input_bfd); @@ -920,7 +949,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, const char *sym_name; bfd_reloc_status_type r = bfd_reloc_ok; const char *errmsg = NULL; - bfd_boolean unresolved_reloc = FALSE; + bool unresolved_reloc = false; h = NULL; r_type = ELF32_R_TYPE (rel->r_info); @@ -932,7 +961,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, _bfd_error_handler (_("%pB: unsupported relocation type %#x"), input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); - ret = FALSE; + ret = false; continue; } @@ -982,12 +1011,12 @@ microblaze_elf_relocate_section (bfd *output_bfd, else { bfd_vma relocation; - bfd_boolean resolved_to_zero; + bool resolved_to_zero; /* This is a final link. */ sym = NULL; sec = NULL; - unresolved_reloc = FALSE; + unresolved_reloc = false; if (r_symndx < symtab_hdr->sh_info) { @@ -1005,8 +1034,8 @@ microblaze_elf_relocate_section (bfd *output_bfd, else { /* External symbol. */ - bfd_boolean warned ATTRIBUTE_UNUSED; - bfd_boolean ignored ATTRIBUTE_UNUSED; + bool warned ATTRIBUTE_UNUSED; + bool ignored ATTRIBUTE_UNUSED; RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, r_symndx, symtab_hdr, sym_hashes, @@ -1034,7 +1063,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, /* Only relocate if the symbol is defined. */ if (sec) { - name = bfd_get_section_name (sec->owner, sec); + name = bfd_section_name (sec); if (strcmp (name, ".sdata2") == 0 || strcmp (name, ".sbss2") == 0) @@ -1043,7 +1072,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, microblaze_elf_final_sdp (info); if (ro_small_data_pointer == 0) { - ret = FALSE; + ret = false; r = bfd_reloc_undefined; goto check_reloc; } @@ -1068,7 +1097,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, microblaze_elf_howto_table[(int) r_type]->name, sec); /*bfd_set_error (bfd_error_bad_value); ??? why? */ - ret = FALSE; + ret = false; continue; } } @@ -1082,7 +1111,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, /* Only relocate if the symbol is defined. */ if (sec) { - name = bfd_get_section_name (sec->owner, sec); + name = bfd_section_name (sec); if (strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0) @@ -1091,7 +1120,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, microblaze_elf_final_sdp (info); if (rw_small_data_pointer == 0) { - ret = FALSE; + ret = false; r = bfd_reloc_undefined; goto check_reloc; } @@ -1116,7 +1145,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, microblaze_elf_howto_table[(int) r_type]->name, sec); /*bfd_set_error (bfd_error_bad_value); ??? why? */ - ret = FALSE; + ret = false; continue; } } @@ -1139,6 +1168,18 @@ microblaze_elf_relocate_section (bfd *output_bfd, contents + offset + endian + INST_WORD_SIZE); break; + case (int) R_MICROBLAZE_TEXTPCREL_64: + relocation = input_section->output_section->vma; + relocation -= (input_section->output_section->vma + + input_section->output_offset + + offset + INST_WORD_SIZE); + relocation += addend; + bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, + contents + offset + endian); + bfd_put_16 (input_bfd, relocation & 0xffff, + contents + offset + endian + INST_WORD_SIZE); + break; + case (int) R_MICROBLAZE_PLT_64: { bfd_vma immediate; @@ -1148,7 +1189,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, relocation = (htab->elf.splt->output_section->vma + htab->elf.splt->output_offset + h->plt.offset); - unresolved_reloc = FALSE; + unresolved_reloc = false; immediate = relocation - (input_section->output_section->vma + input_section->output_offset + offset + INST_WORD_SIZE); @@ -1185,7 +1226,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, unsigned long indx; bfd_vma static_value; - bfd_boolean need_relocs = FALSE; + bool need_relocs = false; if (htab->elf.sgot == NULL) abort (); @@ -1227,7 +1268,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, /* Symbol index to use for relocs */ if (h != NULL) { - bfd_boolean dyn = + bool dyn = elf_hash_table (info)->dynamic_sections_created; if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, @@ -1244,7 +1285,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT && !resolved_to_zero) || h->root.type != bfd_link_hash_undefweak)) - need_relocs = TRUE; + need_relocs = true; /* 2. Compute/Emit Static value of r-expression */ static_value = relocation + addend; @@ -1350,7 +1391,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, bfd_put_16 (input_bfd, relocation & 0xffff, contents + offset + endian + INST_WORD_SIZE); - unresolved_reloc = FALSE; + unresolved_reloc = false; break; } @@ -1389,6 +1430,8 @@ microblaze_elf_relocate_section (bfd *output_bfd, bfd_put_16 (input_bfd, relocation & 0xffff, contents + offset + 2 + INST_WORD_SIZE); break; + case (int) R_MICROBLAZE_TEXTREL_64: + case (int) R_MICROBLAZE_TEXTREL_32_LO: case (int) R_MICROBLAZE_64_PCREL : case (int) R_MICROBLAZE_64: case (int) R_MICROBLAZE_32: @@ -1407,11 +1450,22 @@ microblaze_elf_relocate_section (bfd *output_bfd, relocation -= (input_section->output_section->vma + input_section->output_offset + offset + INST_WORD_SIZE); - bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, + else if (r_type == R_MICROBLAZE_TEXTREL_64 + || r_type == R_MICROBLAZE_TEXTREL_32_LO) + relocation -= input_section->output_section->vma; + + if (r_type == R_MICROBLAZE_TEXTREL_32_LO) + bfd_put_16 (input_bfd, relocation & 0xffff, + contents + offset + endian); + + else + { + bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, contents + offset + endian); - bfd_put_16 (input_bfd, relocation & 0xffff, + bfd_put_16 (input_bfd, relocation & 0xffff, contents + offset + endian + INST_WORD_SIZE); } + } break; } @@ -1436,7 +1490,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, { Elf_Internal_Rela outrel; bfd_byte *loc; - bfd_boolean skip; + bool skip; /* When generating a shared object, these relocations are copied into the output file to be resolved at run @@ -1444,15 +1498,15 @@ microblaze_elf_relocate_section (bfd *output_bfd, BFD_ASSERT (sreloc != NULL); - skip = FALSE; + skip = false; 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; + skip = true; outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); @@ -1482,7 +1536,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, (_("%pB: probably compiled without -fPIC?"), input_bfd); bfd_set_error (bfd_error_bad_value); - return FALSE; + return false; } } @@ -1502,11 +1556,24 @@ microblaze_elf_relocate_section (bfd *output_bfd, relocation -= (input_section->output_section->vma + input_section->output_offset + offset + INST_WORD_SIZE); - bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, - contents + offset + endian); - bfd_put_16 (input_bfd, relocation & 0xffff, - contents + offset + endian + INST_WORD_SIZE); - } + else if (r_type == R_MICROBLAZE_TEXTREL_64 + || r_type == R_MICROBLAZE_TEXTREL_32_LO) + relocation -= input_section->output_section->vma; + + if (r_type == R_MICROBLAZE_TEXTREL_32_LO) + { + bfd_put_16 (input_bfd, relocation & 0xffff, + contents + offset + endian); + } + else + { + bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, + contents + offset + endian); + bfd_put_16 (input_bfd, relocation & 0xffff, + contents + offset + endian + + INST_WORD_SIZE); + } + } break; } } @@ -1533,7 +1600,7 @@ microblaze_elf_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 (errmsg != NULL) @@ -1549,7 +1616,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, case bfd_reloc_undefined: (*info->callbacks->undefined_symbol) - (info, name, input_bfd, input_section, offset, TRUE); + (info, name, input_bfd, input_section, offset, true); break; case bfd_reloc_outofrange: @@ -1631,11 +1698,11 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val) bfd_put_32 (abfd, instr_lo, bfd_addr + INST_WORD_SIZE); } -static bfd_boolean +static bool microblaze_elf_relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info, - bfd_boolean *again) + bool *again) { Elf_Internal_Shdr *symtab_hdr; Elf_Internal_Rela *internal_relocs; @@ -1656,14 +1723,14 @@ microblaze_elf_relax_section (bfd *abfd, /* We only do this once per section. We may be able to delete some code by running multiple passes, but it is not worth it. */ - *again = FALSE; + *again = false; /* Only do this for a text section. */ if (bfd_link_relocatable (link_info) || (sec->flags & SEC_RELOC) == 0 || (sec->reloc_count == 0) || (sec->flags & SEC_CODE) == 0) - return TRUE; + return true; BFD_ASSERT ((sec->size > 0) || (sec->rawsize > 0)); @@ -1699,7 +1766,8 @@ microblaze_elf_relax_section (bfd *abfd, { bfd_vma symval; if ((ELF32_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64_PCREL) - && (ELF32_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64 )) + && (ELF32_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64) + && (ELF32_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_TEXTREL_64)) continue; /* Can't delete this reloc. */ /* Get the section contents. */ @@ -1769,6 +1837,10 @@ microblaze_elf_relax_section (bfd *abfd, + sec->output_section->vma + sec->output_offset); } + else if (ELF32_R_TYPE (irel->r_info) == (int) R_MICROBLAZE_TEXTREL_64) + { + symval = symval + irel->r_addend - (sec->output_section->vma); + } else symval += irel->r_addend; @@ -1791,9 +1863,13 @@ microblaze_elf_relax_section (bfd *abfd, irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), (int) R_MICROBLAZE_32_LO); break; + case R_MICROBLAZE_TEXTREL_64: + irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), + (int) R_MICROBLAZE_TEXTREL_32_LO); + break; default: /* Cannot happen. */ - BFD_ASSERT (FALSE); + BFD_ASSERT (false); } } } /* Loop through all relocations. */ @@ -1817,6 +1893,8 @@ microblaze_elf_relax_section (bfd *abfd, break; case R_MICROBLAZE_64_PCREL: break; + case R_MICROBLAZE_TEXTREL_64: + case R_MICROBLAZE_TEXTREL_32_LO: case R_MICROBLAZE_64: case R_MICROBLAZE_32_LO: /* If this reloc is against a symbol defined in this @@ -1879,7 +1957,7 @@ microblaze_elf_relax_section (bfd *abfd, /* We always cache the relocs. Perhaps, if info->keep_memory is FALSE, we should free them, if we are permitted to. */ - irelocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, TRUE); + irelocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, true); if (irelocs == NULL) goto error_return; @@ -1953,7 +2031,10 @@ microblaze_elf_relax_section (bfd *abfd, } } else if ((ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_PCREL_LO) - || (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_LO)) + || (ELF32_R_TYPE (irelscan->r_info) + == (int) R_MICROBLAZE_32_LO) + || (ELF32_R_TYPE (irelscan->r_info) + == (int) R_MICROBLAZE_TEXTREL_32_LO)) { isym = isymbuf + ELF32_R_SYM (irelscan->r_info); @@ -1997,7 +2078,9 @@ microblaze_elf_relax_section (bfd *abfd, } } - if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64) + if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64 + || (ELF32_R_TYPE (irelscan->r_info) + == (int) R_MICROBLAZE_TEXTREL_64)) { isym = isymbuf + ELF32_R_SYM (irelscan->r_info); @@ -2143,11 +2226,8 @@ microblaze_elf_relax_section (bfd *abfd, symtab_hdr->contents = (bfd_byte *) isymbuf; } - if (free_relocs != NULL) - { - free (free_relocs); - free_relocs = NULL; - } + free (free_relocs); + free_relocs = NULL; if (free_contents != NULL) { @@ -2161,26 +2241,21 @@ microblaze_elf_relax_section (bfd *abfd, if (sec->relax_count == 0) { - *again = FALSE; + *again = false; free (sec->relax); sec->relax = NULL; } else - *again = TRUE; - return TRUE; + *again = true; + return true; error_return: - if (free_relocs != NULL) - free (free_relocs); - if (free_contents != NULL) - free (free_contents); - if (sec->relax != NULL) - { - free (sec->relax); - sec->relax = NULL; - sec->relax_count = 0; - } - return FALSE; + free (free_relocs); + free (free_contents); + free (sec->relax); + sec->relax = NULL; + sec->relax_count = 0; + return false; } /* Return the section that should be marked against GC for a given @@ -2214,7 +2289,7 @@ microblaze_elf_gc_mark_hook (asection *sec, #define PLT_ENTRY_WORD_2 0x98186000 /* "brad r12". */ #define PLT_ENTRY_WORD_3 0x80000000 /* "nop". */ -static bfd_boolean +static bool update_local_sym_info (bfd *abfd, Elf_Internal_Shdr *symtab_hdr, unsigned long r_symndx, @@ -2230,7 +2305,7 @@ update_local_sym_info (bfd *abfd, size *= (sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks)); local_got_refcounts = bfd_zalloc (abfd, size); if (local_got_refcounts == NULL) - return FALSE; + return false; elf_local_got_refcounts (abfd) = local_got_refcounts; } @@ -2239,11 +2314,11 @@ update_local_sym_info (bfd *abfd, local_got_tls_masks[r_symndx] |= tls_type; local_got_refcounts[r_symndx] += 1; - return TRUE; + return true; } /* Look through the relocs for a section during the first phase. */ -static bfd_boolean +static bool microblaze_elf_check_relocs (bfd * abfd, struct bfd_link_info * info, asection * sec, @@ -2258,11 +2333,11 @@ microblaze_elf_check_relocs (bfd * abfd, asection *sreloc = NULL; if (bfd_link_relocatable (info)) - return TRUE; + return true; htab = elf32_mb_hash_table (info); if (htab == NULL) - return FALSE; + return false; symtab_hdr = & elf_tdata (abfd)->symtab_hdr; sym_hashes = elf_sym_hashes (abfd); @@ -2298,14 +2373,14 @@ microblaze_elf_check_relocs (bfd * abfd, Reconstruct it for later use during GC. */ case R_MICROBLAZE_GNU_VTINHERIT: if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) - return FALSE; + return false; break; /* This relocation describes which C++ vtable entries are actually used. Record for later use during GC. */ case R_MICROBLAZE_GNU_VTENTRY: if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) - return FALSE; + return false; break; /* This relocation requires .plt entry. */ @@ -2333,7 +2408,7 @@ microblaze_elf_check_relocs (bfd * abfd, if (htab->elf.dynobj == NULL) htab->elf.dynobj = abfd; if (!_bfd_elf_create_got_section (htab->elf.dynobj, info)) - return FALSE; + return false; } if (h != NULL) { @@ -2343,7 +2418,7 @@ microblaze_elf_check_relocs (bfd * abfd, else { if (! update_local_sym_info(abfd, symtab_hdr, r_symndx, tls_type) ) - return FALSE; + return false; } break; @@ -2354,7 +2429,7 @@ microblaze_elf_check_relocs (bfd * abfd, if (htab->elf.dynobj == NULL) htab->elf.dynobj = abfd; if (!_bfd_elf_create_got_section (htab->elf.dynobj, info)) - return FALSE; + return false; } break; @@ -2427,13 +2502,13 @@ microblaze_elf_check_relocs (bfd * abfd, sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj, 2, abfd, 1); 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) - head = &((struct elf32_mb_link_hash_entry *) h)->dyn_relocs; + head = &h->dyn_relocs; else { /* Track dynamic relocs needed for local syms too. @@ -2444,14 +2519,14 @@ microblaze_elf_check_relocs (bfd * abfd, Elf_Internal_Sym *isym; void *vpp; - isym = bfd_sym_from_r_symndx (&htab->sym_sec, + isym = bfd_sym_from_r_symndx (&htab->elf.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) - return FALSE; + return false; vpp = &elf_section_data (s)->local_dynrel; head = (struct elf_dyn_relocs **) vpp; @@ -2460,11 +2535,11 @@ microblaze_elf_check_relocs (bfd * abfd, 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_alloc (htab->elf.dynobj, amt)); if (p == NULL) - return FALSE; + return false; p->next = *head; *head = p; p->sec = sec; @@ -2481,7 +2556,7 @@ microblaze_elf_check_relocs (bfd * abfd, } } - return TRUE; + return true; } /* Copy the extra info we tack onto an elf_link_hash_entry. */ @@ -2496,63 +2571,12 @@ microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf32_mb_link_hash_entry *) dir; eind = (struct elf32_mb_link_hash_entry *) ind; - if (eind->dyn_relocs != NULL) - { - if (edir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - if (ind->root.type == bfd_link_hash_indirect) - abort (); - - /* Add reloc counts against the weak sym to the strong 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; - } - edir->tls_mask |= eind->tls_mask; _bfd_elf_link_hash_copy_indirect (info, dir, ind); } -/* 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 = elf32_mb_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; -} - -static bfd_boolean +static bool microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, struct elf_link_hash_entry *h) { @@ -2562,7 +2586,7 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, htab = elf32_mb_hash_table (info); if (htab == NULL) - return FALSE; + return false; /* If this is a function, put it in the procedure linkage table. We will fill in the contents of the procedure linkage table later, @@ -2584,7 +2608,7 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_plt = 0; } - return TRUE; + return true; } else /* It's possible that we incorrectly decided a .plt reloc was @@ -2603,7 +2627,7 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, BFD_ASSERT (def->root.type == bfd_link_hash_defined); h->root.u.def.section = def->root.u.def.section; h->root.u.def.value = def->root.u.def.value; - return TRUE; + return true; } /* This is a reference to a symbol defined by a dynamic object which @@ -2614,26 +2638,26 @@ microblaze_elf_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 we don't find any dynamic relocs in read-only sections, then we'll be keeping the dynamic relocs and avoiding the copy reloc. */ - if (!readonly_dynrelocs (h)) + if (!_bfd_elf_readonly_dynrelocs (h)) { h->non_got_ref = 0; - return TRUE; + return true; } /* We must allocate the symbol in our .dynbss section, which will @@ -2675,8 +2699,8 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two)); if (power_of_two > s->alignment_power) { - if (!bfd_set_section_alignment (s->owner, s, power_of_two)) - return FALSE; + if (!bfd_set_section_alignment (s, power_of_two)) + return false; } /* Define the symbol as being at this point in the section. */ @@ -2685,13 +2709,13 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, /* Increment the section size to make room for the symbol. */ s->size += h->size; - return TRUE; + return true; } /* Allocate space in .plt, .got and associated reloc sections for dynamic relocs. */ -static bfd_boolean +static bool allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) { struct bfd_link_info *info; @@ -2700,12 +2724,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) struct elf_dyn_relocs *p; if (h->root.type == bfd_link_hash_indirect) - return TRUE; + return true; info = (struct bfd_link_info *) dat; htab = elf32_mb_hash_table (info); if (htab == NULL) - return FALSE; + return false; if (htab->elf.dynamic_sections_created && h->plt.refcount > 0) @@ -2716,7 +2740,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) && !h->forced_local) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; + return false; } if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h)) @@ -2775,7 +2799,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) && !h->forced_local) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; + return false; } need = 0; @@ -2815,8 +2839,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) else 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 @@ -2832,7 +2856,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) { 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; @@ -2843,7 +2867,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) } } else if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)) - eh->dyn_relocs = NULL; + h->dyn_relocs = NULL; } else { @@ -2864,7 +2888,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) && !h->forced_local) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; + return false; } /* If that succeeded, we know we'll be keeping all the @@ -2873,24 +2897,24 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) 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 = elf_section_data (p->sec)->sreloc; sreloc->size += p->count * sizeof (Elf32_External_Rela); } - return TRUE; + return true; } /* Set the sizes of the dynamic sections. */ -static bfd_boolean +static bool microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) { @@ -2901,7 +2925,7 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, htab = elf32_mb_hash_table (info); if (htab == NULL) - return FALSE; + return false; dynobj = htab->elf.dynobj; BFD_ASSERT (dynobj != NULL); @@ -3017,16 +3041,16 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, for (s = dynobj->sections; s != NULL; s = s->next) { const char *name; - bfd_boolean strip = FALSE; + bool strip = false; if ((s->flags & SEC_LINKER_CREATED) == 0) continue; /* It's OK to base decisions on the section name, because none of the dynobj section names depend upon the input files. */ - name = bfd_get_section_name (dynobj, s); + name = bfd_section_name (s); - if (strncmp (name, ".rela", 5) == 0) + if (startswith (name, ".rela")) { if (s->size == 0) { @@ -3039,7 +3063,7 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, adjust_dynamic_symbol is called, and it is that function which decides whether anything needs to go into these sections. */ - strip = TRUE; + strip = true; } else { @@ -3072,54 +3096,18 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, contents to zero. */ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); if (s->contents == NULL && s->size != 0) - return FALSE; + return false; } - if (elf_hash_table (info)->dynamic_sections_created) - { - /* Add some entries to the .dynamic section. We fill in the - values later, in microblaze_elf_finish_dynamic_sections, but we - must add the entries now so that we get the correct size for - the .dynamic section. The DT_DEBUG entry is filled in by the - dynamic linker and used by the debugger. */ -#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 (!add_dynamic_entry (DT_RELA, 0) - || !add_dynamic_entry (DT_RELASZ, 0) - || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) - return FALSE; - - if (htab->elf.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) - || !add_dynamic_entry (DT_BIND_NOW, 1)) - return FALSE; - } - - if (info->flags & DF_TEXTREL) - { - if (!add_dynamic_entry (DT_TEXTREL, 0)) - return FALSE; - } - } -#undef add_dynamic_entry - return TRUE; + /* ??? Force DF_BIND_NOW? */ + info->flags |= DF_BIND_NOW; + return _bfd_elf_add_dynamic_tags (output_bfd, info, true); } /* Finish up dynamic symbol handling. We set the contents of various dynamic sections here. */ -static bfd_boolean +static bool microblaze_elf_finish_dynamic_symbol (bfd *output_bfd, struct bfd_link_info *info, struct elf_link_hash_entry *h, @@ -3130,7 +3118,7 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd, htab = elf32_mb_hash_table (info); if (htab == NULL) - return FALSE; + return false; if (h->plt.offset != (bfd_vma) -1) { @@ -3284,13 +3272,13 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd, || h == htab->elf.hplt) sym->st_shndx = SHN_ABS; - return TRUE; + return true; } /* Finish up the dynamic sections. */ -static bfd_boolean +static bool microblaze_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) { @@ -3300,7 +3288,7 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd, htab = elf32_mb_hash_table (info); if (htab == NULL) - return FALSE; + return false; dynobj = htab->elf.dynobj; @@ -3317,7 +3305,7 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd, { Elf_Internal_Dyn dyn; asection *s; - bfd_boolean size; + bool size; bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); @@ -3325,17 +3313,17 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd, { case DT_PLTGOT: s = htab->elf.sgotplt; - size = FALSE; + size = false; break; case DT_PLTRELSZ: s = htab->elf.srelplt; - size = TRUE; + size = true; break; case DT_JMPREL: s = htab->elf.srelplt; - size = FALSE; + size = false; break; default: @@ -3364,9 +3352,10 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd, memset (splt->contents, 0, PLT_ENTRY_SIZE); bfd_put_32 (output_bfd, (bfd_vma) 0x80000000 /* nop. */, splt->contents + splt->size - 4); - } - elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; + if (splt->output_section != bfd_abs_section_ptr) + elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; + } } /* Set the first entry in the global offset table to the address of @@ -3386,13 +3375,13 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd, if (htab->elf.sgot && htab->elf.sgot->size > 0) elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = 4; - return TRUE; + return true; } /* Hook called by the linker routine which adds symbols from an object file. We use it to put .comm items in .sbss, and not .bss. */ -static bfd_boolean +static bool microblaze_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *sym, @@ -3409,13 +3398,13 @@ microblaze_elf_add_symbol_hook (bfd *abfd, put into .sbss. */ *secp = bfd_make_section_old_way (abfd, ".sbss"); if (*secp == NULL - || ! bfd_set_section_flags (abfd, *secp, SEC_IS_COMMON)) - return FALSE; + || !bfd_set_section_flags (*secp, SEC_IS_COMMON | SEC_SMALL_DATA)) + return false; *valp = sym->st_size; } - return TRUE; + return true; } #define TARGET_LITTLE_SYM microblaze_elf32_le_vec