diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-08-18 05:51:03 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-08-18 05:51:19 -0700 |
commit | 0e1862bb401f47716446aef143b2bf7a4563f541 (patch) | |
tree | 8410cdece79e8df2f1394b53d1e992736323baac /bfd/elfnn-aarch64.c | |
parent | b2a33439909493f5bf93ada871bd588f365d61f4 (diff) | |
download | fsf-binutils-gdb-0e1862bb401f47716446aef143b2bf7a4563f541.zip fsf-binutils-gdb-0e1862bb401f47716446aef143b2bf7a4563f541.tar.gz fsf-binutils-gdb-0e1862bb401f47716446aef143b2bf7a4563f541.tar.bz2 |
Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs. This
patch adds an "output_type" field:
enum output_type
{
type_unknown = 0,
type_executable,
type_dll,
type_relocatable
};
and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC. Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.
bfd/
* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.
include/
* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.
ld/
* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.
Diffstat (limited to 'bfd/elfnn-aarch64.c')
-rw-r--r-- | bfd/elfnn-aarch64.c | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index fe10be6..9773e3e 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -4066,8 +4066,8 @@ aarch64_calculate_got_entry_vma (struct elf_link_hash_entry *h, BFD_ASSERT (basegot != NULL); off = h->got.offset; BFD_ASSERT (off != (bfd_vma) - 1); - if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) - || (info->shared + if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h) + || (bfd_link_pic (info) && SYMBOL_REFERENCES_LOCAL (info, h)) || (ELF_ST_VISIBILITY (h->other) && h->root.type == bfd_link_hash_undefweak)) @@ -4229,7 +4229,7 @@ aarch64_can_relax_tls (bfd *input_bfd, if (symbol_got_type == GOT_TLS_IE && GOT_TLS_GD_ANY_P (reloc_got_type)) return TRUE; - if (info->shared) + if (bfd_link_pic (info)) return FALSE; if (h && h->root.type == bfd_link_hash_undefweak) @@ -4669,7 +4669,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, /* Generate dynamic relocation only when there is a non-GOT reference in a shared object. */ - if (info->shared && h->non_got_ref) + if (bfd_link_pic (info) && h->non_got_ref) { Elf_Internal_Rela outrel; asection *sreloc; @@ -4689,7 +4689,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, if (h->dynindx == -1 || h->forced_local - || info->executable) + || bfd_link_executable (info)) { /* This symbol is resolved locally. */ outrel.r_info = ELFNN_R_INFO (0, AARCH64_R (IRELATIVE)); @@ -4810,7 +4810,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, /* When generating a shared object or relocatable executable, these relocations are copied into the output file to be resolved at run time. */ - if (((info->shared == TRUE) || globals->root.is_relocatable_executable) + if (((bfd_link_pic (info) == TRUE) + || globals->root.is_relocatable_executable) && (input_section->flags & SEC_ALLOC) && (h == NULL || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT @@ -4845,7 +4846,9 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, memset (&outrel, 0, sizeof outrel); else if (h != NULL && h->dynindx != -1 - && (!info->shared || !SYMBOLIC_BIND (info, h) || !h->def_regular)) + && (!bfd_link_pic (info) + || !SYMBOLIC_BIND (info, h) + || !h->def_regular)) outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type); else { @@ -4936,7 +4939,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, case BFD_RELOC_AARCH64_ADR_HI21_PCREL: case BFD_RELOC_AARCH64_ADR_LO21_PCREL: case BFD_RELOC_AARCH64_LD_LO19_PCREL: - if (info->shared + if (bfd_link_pic (info) && (input_section->flags & SEC_ALLOC) != 0 && (input_section->flags & SEC_READONLY) != 0 && h != NULL @@ -5026,7 +5029,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, { bfd_put_64 (output_bfd, value, base_got->contents + off); - if (info->shared) + if (bfd_link_pic (info)) { asection *s; Elf_Internal_Rela outrel; @@ -5463,7 +5466,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); /* Relocate against local STT_GNU_IFUNC symbol. */ - if (!info->relocatable + if (!bfd_link_relocatable (info) && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) { h = elfNN_aarch64_get_local_sym_hash (globals, input_bfd, @@ -5492,7 +5495,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, rel, 1, relend, howto, 0, contents); - if (info->relocatable) + if (bfd_link_relocatable (info)) continue; if (h != NULL) @@ -5577,7 +5580,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, indx = h && h->dynindx != -1 ? h->dynindx : 0; need_relocs = - (info->shared || indx != 0) && + (bfd_link_pic (info) || indx != 0) && (h == NULL || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak); @@ -5670,7 +5673,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd, indx = h && h->dynindx != -1 ? h->dynindx : 0; need_relocs = - (info->shared || indx != 0) && + (bfd_link_pic (info) || indx != 0) && (h == NULL || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak); @@ -6020,7 +6023,7 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd, struct elf_aarch64_local_symbol *locals; const Elf_Internal_Rela *rel, *relend; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; htab = elf_aarch64_hash_table (info); @@ -6157,7 +6160,7 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd, case BFD_RELOC_AARCH64_MOVW_G2_NC: case BFD_RELOC_AARCH64_MOVW_G3: case BFD_RELOC_AARCH64_NN: - if (h != NULL && info->executable) + if (h != NULL && bfd_link_executable (info)) { if (h->plt.refcount > 0) h->plt.refcount -= 1; @@ -6230,7 +6233,7 @@ elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info, only references to the symbol are via the global offset table. For such cases we need not do anything here; the relocations will be handled correctly by relocate_section. */ - if (info->shared) + if (bfd_link_pic (info)) return TRUE; /* If there are no references to this symbol that do not use the @@ -6366,7 +6369,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, struct elf_aarch64_link_hash_table *htab; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; BFD_ASSERT (is_aarch64_elf (abfd)); @@ -6482,7 +6485,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, if (h != NULL) { - if (!info->shared) + if (!bfd_link_pic (info)) h->non_got_ref = 1; h->plt.refcount += 1; @@ -6491,7 +6494,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, /* No need to do anything if we're not creating a shared object. */ - if (! info->shared) + if (! bfd_link_pic (info)) break; { @@ -6663,7 +6666,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, case BFD_RELOC_AARCH64_MOVW_G1_NC: case BFD_RELOC_AARCH64_MOVW_G2_NC: case BFD_RELOC_AARCH64_MOVW_G3: - if (info->shared) + if (bfd_link_pic (info)) { int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; (*_bfd_error_handler) @@ -6678,7 +6681,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: case BFD_RELOC_AARCH64_ADR_LO21_PCREL: - if (h != NULL && info->executable) + if (h != NULL && bfd_link_executable (info)) { /* If this reloc is in a read-only section, we might need a copy reloc. We can't check reliably at this @@ -7281,10 +7284,10 @@ elfNN_aarch64_create_dynamic_sections (bfd *dynobj, htab = elf_aarch64_hash_table (info); htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss"); - if (!info->shared) + if (!bfd_link_pic (info)) htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss"); - if (!htab->sdynbss || (!info->shared && !htab->srelbss)) + if (!htab->sdynbss || (!bfd_link_pic (info) && !htab->srelbss)) abort (); return TRUE; @@ -7336,7 +7339,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) return FALSE; } - if (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) + if (bfd_link_pic (info) || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h)) { asection *s = htab->root.splt; @@ -7352,7 +7355,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) location in the .plt. This is required to make function pointers compare as equal between the normal executable and the shared library. */ - if (!info->shared && !h->def_regular) + if (!bfd_link_pic (info) && !h->def_regular) { h->root.u.def.section = s; h->root.u.def.value = h->plt.offset; @@ -7426,7 +7429,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) htab->root.sgot->size += GOT_ENTRY_SIZE; if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) - && (info->shared + && (bfd_link_pic (info) || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) { htab->root.srelgot->size += RELOC_SIZE (htab); @@ -7459,7 +7462,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) indx = h && h->dynindx != -1 ? h->dynindx : 0; if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) - && (info->shared + && (bfd_link_pic (info) || indx != 0 || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) { @@ -7496,7 +7499,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) space for pc-relative relocs that have become local due to symbol visibility changes. */ - if (info->shared) + if (bfd_link_pic (info)) { /* Relocs that use pc_count are those that appear on a call insn, or certain REL relocs that can generated via assembly. @@ -7708,7 +7711,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab->root.dynamic_sections_created) { - if (info->executable) + if (bfd_link_executable (info)) { s = bfd_get_linker_section (dynobj, ".interp"); if (s == NULL) @@ -7794,7 +7797,7 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, { } - if (info->shared) + if (bfd_link_pic (info)) { if (got_type & GOT_TLSDESC_GD) { @@ -7947,7 +7950,7 @@ 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 (info->executable) + if (bfd_link_executable (info)) { if (!add_dynamic_entry (DT_DEBUG, 0)) return FALSE; @@ -8088,7 +8091,7 @@ elfNN_aarch64_create_small_pltn_entry (struct elf_link_hash_entry *h, rela.r_offset = gotplt_entry_address; if (h->dynindx == -1 - || ((info->executable + || ((bfd_link_executable (info) || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) && h->def_regular && h->type == STT_GNU_IFUNC)) @@ -8123,7 +8126,7 @@ elfNN_aarch64_always_size_sections (bfd *output_bfd, { asection *tls_sec; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; tls_sec = elf_hash_table (info)->tls_sec; @@ -8193,7 +8196,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, /* This symbol has an entry in the procedure linkage table. Set it up. */ if ((h->dynindx == -1 - && !((h->forced_local || info->executable) + && !((h->forced_local || bfd_link_executable (info)) && h->def_regular && h->type == STT_GNU_IFUNC)) || plt == NULL @@ -8238,7 +8241,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, if (h->def_regular && h->type == STT_GNU_IFUNC) { - if (info->shared) + if (bfd_link_pic (info)) { /* Generate R_AARCH64_GLOB_DAT. */ goto do_glob_dat; @@ -8262,7 +8265,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd, return TRUE; } } - else if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h)) + else if (bfd_link_pic (info) && SYMBOL_REFERENCES_LOCAL (info, h)) { if (!h->def_regular) return FALSE; |