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/elf64-alpha.c | |
parent | b2a33439909493f5bf93ada871bd588f365d61f4 (diff) | |
download | gdb-0e1862bb401f47716446aef143b2bf7a4563f541.zip gdb-0e1862bb401f47716446aef143b2bf7a4563f541.tar.gz 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/elf64-alpha.c')
-rw-r--r-- | bfd/elf64-alpha.c | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index cfd328a..f67b0af 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -1227,7 +1227,7 @@ elf64_alpha_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, asection **secp, bfd_vma *valp) { if (sym->st_shndx == SHN_COMMON - && !info->relocatable + && !bfd_link_relocatable (info) && sym->st_size <= elf_gp_size (abfd)) { /* Common symbols less than or equal to -G nn bytes are @@ -1770,7 +1770,7 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Rela *rel, *relend; bfd_size_type amt; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; /* Don't do anything special with non-loaded, non-alloced sections. @@ -1830,7 +1830,7 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, have yet been processed. Do something with what we know, as this may help reduce memory usage and processing time later. */ maybe_dynamic = FALSE; - if (h && ((info->shared + if (h && ((bfd_link_pic (info) && (!info->symbolic || info->unresolved_syms_in_shared_libs == RM_IGNORE)) || !h->root.def_regular @@ -1871,7 +1871,7 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_ALPHA_REFLONG: case R_ALPHA_REFQUAD: - if (info->shared || maybe_dynamic) + if (bfd_link_pic (info) || maybe_dynamic) need = NEED_DYNREL; break; @@ -1891,12 +1891,12 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_ALPHA_GOTTPREL: need = NEED_GOT | NEED_GOT_ENTRY; gotent_flags = ALPHA_ELF_LINK_HASH_TLS_IE; - if (info->shared) + if (bfd_link_pic (info)) info->flags |= DF_STATIC_TLS; break; case R_ALPHA_TPREL64: - if (info->shared && !info->pie) + if (bfd_link_pic (info) && !bfd_link_pie (info)) { info->flags |= DF_STATIC_TLS; need = NEED_DYNREL; @@ -1988,7 +1988,7 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, else rent->count++; } - else if (info->shared) + else if (bfd_link_pic (info)) { /* If this is a shared library, and the section is to be loaded into memory, we need a RELATIVE reloc. */ @@ -2033,7 +2033,7 @@ elf64_alpha_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, struct alpha_elf_link_hash_entry **sym_hashes; const Elf_Internal_Rela *rel, *relend; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; symtab_hdr = &elf_symtab_hdr (abfd); @@ -2644,7 +2644,7 @@ elf64_alpha_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED, bfd *i; struct alpha_elf_link_hash_table * htab; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; htab = alpha_elf_hash_table (info); @@ -2735,14 +2735,14 @@ elf64_alpha_calc_dynrel_sizes (struct alpha_elf_link_hash_entry *h, /* If the symbol is a hidden undefined weak, then we never have any relocations. Avoid the loop which may want to add RELATIVE relocs - based on info->shared. */ + based on bfd_link_pic (info). */ if (h->root.root.type == bfd_link_hash_undefweak && !dynamic) return TRUE; for (relent = h->reloc_entries; relent; relent = relent->next) { entries = alpha_dynamic_entries_for_reloc (relent->rtype, dynamic, - info->shared, info->pie); + bfd_link_pic (info), bfd_link_pie (info)); if (entries) { relent->srel->size += @@ -2778,7 +2778,7 @@ elf64_alpha_size_rela_got_1 (struct alpha_elf_link_hash_entry *h, /* If the symbol is a hidden undefined weak, then we never have any relocations. Avoid the loop which may want to add RELATIVE relocs - based on info->shared. */ + based on bfd_link_pic (info). */ if (h->root.root.type == bfd_link_hash_undefweak && !dynamic) return TRUE; @@ -2786,7 +2786,8 @@ elf64_alpha_size_rela_got_1 (struct alpha_elf_link_hash_entry *h, for (gotent = h->got_entries; gotent ; gotent = gotent->next) if (gotent->use_count > 0) entries += alpha_dynamic_entries_for_reloc (gotent->reloc_type, dynamic, - info->shared, info->pie); + bfd_link_pic (info), + bfd_link_pie (info)); if (entries > 0) { @@ -2836,7 +2837,8 @@ elf64_alpha_size_rela_got_section (struct bfd_link_info *info) gotent ; gotent = gotent->next) if (gotent->use_count > 0) entries += (alpha_dynamic_entries_for_reloc - (gotent->reloc_type, 0, info->shared, info->pie)); + (gotent->reloc_type, 0, bfd_link_pic (info), + bfd_link_pie (info))); } } @@ -2875,7 +2877,7 @@ elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (elf_hash_table (info)->dynamic_sections_created) { /* Set the contents of the .interp section to the interpreter. */ - if (info->executable) + if (bfd_link_executable (info)) { s = bfd_get_linker_section (dynobj, ".interp"); BFD_ASSERT (s != NULL); @@ -2961,7 +2963,7 @@ elf64_alpha_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; @@ -3069,7 +3071,8 @@ elf64_alpha_relax_got_load (struct alpha_relax_info *info, bfd_vma symval, /* Can't use local-exec relocations in shared libraries. */ if (r_type == R_ALPHA_GOTTPREL - && (info->link_info->shared && !info->link_info->pie)) + && (bfd_link_pic (info->link_info) + && !bfd_link_pie (info->link_info))) return TRUE; if (r_type == R_ALPHA_LITERAL) @@ -3077,7 +3080,7 @@ elf64_alpha_relax_got_load (struct alpha_relax_info *info, bfd_vma symval, /* Look for nice constant addresses. This includes the not-uncommon special case of 0 for undefweak symbols. */ if ((info->h && info->h->root.root.type == bfd_link_hash_undefweak) - || (!info->link_info->shared + || (!bfd_link_pic (info->link_info) && (symval >= (bfd_vma)-0x8000 || symval < 0x8000))) { disp = 0; @@ -3540,12 +3543,12 @@ elf64_alpha_relax_tls_get_addr (struct alpha_relax_info *info, bfd_vma symval, /* If the symbol is local, and we've already committed to DF_STATIC_TLS, then we might as well relax to IE. */ - else if (info->link_info->shared && !dynamic + else if (bfd_link_pic (info->link_info) && !dynamic && (info->link_info->flags & DF_STATIC_TLS)) ; /* Otherwise we must be building an executable to do anything. */ - else if (info->link_info->shared) + else if (bfd_link_pic (info->link_info)) return TRUE; /* The TLSGD/TLSLDM relocation must be followed by a LITERAL and @@ -3646,7 +3649,7 @@ elf64_alpha_relax_tls_get_addr (struct alpha_relax_info *info, bfd_vma symval, /* Some compilers warn about a Boolean-looking expression being used in a switch. The explicit cast silences them. */ - switch ((int) (!dynamic && !info->link_info->shared)) + switch ((int) (!dynamic && !bfd_link_pic (info->link_info))) { case 1: { @@ -3789,7 +3792,7 @@ elf64_alpha_relax_section (bfd *abfd, asection *sec, /* There's nothing to change, yet. */ *again = FALSE; - if (link_info->relocatable + if (bfd_link_relocatable (link_info) || ((sec->flags & (SEC_CODE | SEC_RELOC | SEC_ALLOC)) != (SEC_CODE | SEC_RELOC | SEC_ALLOC)) || sec->reloc_count == 0) @@ -4206,7 +4209,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (is_alpha_elf (input_bfd)); /* Handle relocatable links with a smaller loop. */ - if (info->relocatable) + if (bfd_link_relocatable (info)) return elf64_alpha_relocate_section_r (output_bfd, info, input_bfd, input_section, contents, relocs, local_syms, local_sections); @@ -4431,7 +4434,9 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, /* If the symbol has been forced local, output a RELATIVE reloc, otherwise it will be handled in finish_dynamic_symbol. */ - if (info->shared && !dynamic_symbol_p && !undef_weak_ref) + if (bfd_link_pic (info) + && !dynamic_symbol_p + && !undef_weak_ref) elf64_alpha_emit_dynrel (output_bfd, info, sgot, srelgot, gotent->got_offset, 0, R_ALPHA_RELATIVE, value); @@ -4581,7 +4586,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, else if (r_type == R_ALPHA_TPREL64) { BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL); - if (!info->shared || info->pie) + if (!bfd_link_pic (info) || bfd_link_pie (info)) { value -= tp_base; goto default_reloc; @@ -4589,7 +4594,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, dynindx = 0; dynaddend = value - dtp_base; } - else if (info->shared + else if (bfd_link_pic (info) && r_symndx != STN_UNDEF && (input_section->flags & SEC_ALLOC) && !undef_weak_ref @@ -4631,7 +4636,8 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, input_bfd, h->root.root.root.string); ret_val = FALSE; } - else if ((info->shared || info->pie) && undef_weak_ref) + else if ((bfd_link_pic (info) || bfd_link_pie (info)) + && undef_weak_ref) { (*_bfd_error_handler) (_("%B: pc-relative relocation against undefined weak symbol %s"), @@ -4664,13 +4670,14 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, gotent->reloc_done = 1; /* Note that the module index for the main program is 1. */ - bfd_put_64 (output_bfd, !info->shared && !dynamic_symbol_p, + bfd_put_64 (output_bfd, + !bfd_link_pic (info) && !dynamic_symbol_p, sgot->contents + gotent->got_offset); /* If the symbol has been forced local, output a DTPMOD64 reloc, otherwise it will be handled in finish_dynamic_symbol. */ - if (info->shared && !dynamic_symbol_p) + if (bfd_link_pic (info) && !dynamic_symbol_p) elf64_alpha_emit_dynrel (output_bfd, info, sgot, srelgot, gotent->got_offset, 0, R_ALPHA_DTPMOD64, 0); @@ -4711,7 +4718,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, case R_ALPHA_TPRELHI: case R_ALPHA_TPRELLO: case R_ALPHA_TPREL16: - if (info->shared && !info->pie) + if (bfd_link_pic (info) && !bfd_link_pie (info)) { (*_bfd_error_handler) (_("%B: TLS local exec code cannot be linked into shared objects"), @@ -4749,7 +4756,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL); if (r_type == R_ALPHA_GOTDTPREL) value -= dtp_base; - else if (!info->shared) + else if (!bfd_link_pic (info)) value -= tp_base; else { |