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/sunos.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/sunos.c')
-rw-r--r-- | bfd/sunos.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/bfd/sunos.c b/bfd/sunos.c index cdf2a31..3ce73b5 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -792,7 +792,7 @@ sunos_create_dynamic_sections (bfd *abfd, } if ((needed && ! sunos_hash_table (info)->dynamic_sections_needed) - || info->shared) + || bfd_link_pic (info)) { bfd *dynobj; @@ -828,7 +828,7 @@ sunos_add_dynamic_symbols (bfd *abfd, { if (! sunos_create_dynamic_sections (abfd, info, ((abfd->flags & DYNAMIC) != 0 - && !info->relocatable))) + && !bfd_link_relocatable (info)))) return FALSE; } @@ -860,7 +860,7 @@ sunos_add_dynamic_symbols (bfd *abfd, /* The native linker seems to just ignore dynamic objects when -r is used. */ - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; /* There's no hope of using a dynamic object which does not exactly @@ -1214,7 +1214,7 @@ bfd_sunos_record_link_assignment (bfd *output_bfd, /* In a shared library, the __DYNAMIC symbol does not appear in the dynamic symbol table. */ - if (! info->shared || strcmp (name, "__DYNAMIC") != 0) + if (! bfd_link_pic (info) || strcmp (name, "__DYNAMIC") != 0) { h->flags |= SUNOS_DEF_REGULAR; @@ -1513,7 +1513,7 @@ sunos_scan_ext_relocs (struct bfd_link_info *info, /* If we are making a shared library, or if the symbol is defined by a dynamic object, we will need a dynamic reloc entry. */ - if (info->shared + if (bfd_link_pic (info) || (h != NULL && (h->flags & SUNOS_DEF_DYNAMIC) != 0 && (h->flags & SUNOS_DEF_REGULAR) == 0)) @@ -1529,7 +1529,7 @@ sunos_scan_ext_relocs (struct bfd_link_info *info, { /* But, if we are creating a shared library, we need to generate an absolute reloc. */ - if (info->shared) + if (bfd_link_pic (info)) { if (dynobj == NULL) { @@ -1559,13 +1559,13 @@ sunos_scan_ext_relocs (struct bfd_link_info *info, continue; if (r_type != RELOC_JMP_TBL - && ! info->shared + && ! bfd_link_pic (info) && ((h->flags & SUNOS_DEF_DYNAMIC) == 0 || (h->flags & SUNOS_DEF_REGULAR) != 0)) continue; if (r_type == RELOC_JMP_TBL - && ! info->shared + && ! bfd_link_pic (info) && (h->flags & SUNOS_DEF_DYNAMIC) == 0 && (h->flags & SUNOS_DEF_REGULAR) == 0) { @@ -1595,10 +1595,10 @@ sunos_scan_ext_relocs (struct bfd_link_info *info, } BFD_ASSERT (r_type == RELOC_JMP_TBL - || info->shared + || bfd_link_pic (info) || (h->flags & SUNOS_REF_REGULAR) != 0); BFD_ASSERT (r_type == RELOC_JMP_TBL - || info->shared + || bfd_link_pic (info) || h->plt_offset != 0 || ((h->root.root.type == bfd_link_hash_defined || h->root.root.type == bfd_link_hash_defweak) @@ -1657,13 +1657,13 @@ sunos_scan_ext_relocs (struct bfd_link_info *info, /* We will also need a dynamic reloc entry, unless this is a JMP_TBL reloc produced by linking PIC compiled code, and we are not making a shared library. */ - if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0) + if (bfd_link_pic (info) || (h->flags & SUNOS_DEF_REGULAR) == 0) srel->size += RELOC_EXT_SIZE; } /* If we are creating a shared library, we need to copy over any reloc other than a jump table reloc. */ - if (info->shared && r_type != RELOC_JMP_TBL) + if (bfd_link_pic (info) && r_type != RELOC_JMP_TBL) srel->size += RELOC_EXT_SIZE; } } @@ -1880,7 +1880,7 @@ bfd_sunos_size_dynamic_sections (bfd *output_bfd, *sneedptr = NULL; *srulesptr = NULL; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; if (output_bfd->xvec != &MY(vec)) @@ -2119,7 +2119,7 @@ sunos_write_dynamic_symbol (bfd *output_bfd, switch (bfd_get_arch (output_bfd)) { case bfd_arch_sparc: - if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0) + if (bfd_link_pic (info) || (h->flags & SUNOS_DEF_REGULAR) == 0) { bfd_put_32 (output_bfd, SPARC_PLT_ENTRY_WORD0, p); bfd_put_32 (output_bfd, @@ -2146,7 +2146,7 @@ sunos_write_dynamic_symbol (bfd *output_bfd, break; case bfd_arch_m68k: - if (! info->shared && (h->flags & SUNOS_DEF_REGULAR) != 0) + if (! bfd_link_pic (info) && (h->flags & SUNOS_DEF_REGULAR) != 0) abort (); bfd_put_16 (output_bfd, M68K_PLT_ENTRY_WORD0, p); bfd_put_32 (output_bfd, (- (h->plt_offset + 2)), p + 2); @@ -2160,7 +2160,7 @@ sunos_write_dynamic_symbol (bfd *output_bfd, /* We also need to add a jump table reloc, unless this is the result of a JMP_TBL reloc from PIC compiled code. */ - if (info->shared || (h->flags & SUNOS_DEF_REGULAR) == 0) + if (bfd_link_pic (info) || (h->flags & SUNOS_DEF_REGULAR) == 0) { BFD_ASSERT (h->dynindx >= 0); BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) @@ -2343,7 +2343,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info, if (h != NULL && h->plt_offset != 0 - && (info->shared + && (bfd_link_pic (info) || (h->flags & SUNOS_DEF_REGULAR) == 0)) { asection *splt; @@ -2451,14 +2451,14 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info, if ((*got_offsetp & 1) == 0) { if (h == NULL - || (! info->shared + || (! bfd_link_pic (info) && ((h->flags & SUNOS_DEF_DYNAMIC) == 0 || (h->flags & SUNOS_DEF_REGULAR) != 0))) PUT_WORD (dynobj, *relocationp, sgot->contents + *got_offsetp); else PUT_WORD (dynobj, 0, sgot->contents + *got_offsetp); - if (info->shared + if (bfd_link_pic (info) || (h != NULL && (h->flags & SUNOS_DEF_DYNAMIC) != 0 && (h->flags & SUNOS_DEF_REGULAR) == 0)) @@ -2574,7 +2574,7 @@ sunos_check_dynamic_reloc (struct bfd_link_info *info, if (! sunos_hash_table (info)->dynamic_sections_needed) return TRUE; - if (! info->shared) + if (! bfd_link_pic (info)) { if (h == NULL || h->dynindx == -1 @@ -2726,7 +2726,7 @@ sunos_finish_dynamic_link (bfd *abfd, struct bfd_link_info *info) dynamic information, unless this is a shared library. */ s = bfd_get_linker_section (dynobj, ".got"); BFD_ASSERT (s != NULL); - if (info->shared || sdyn->size == 0) + if (bfd_link_pic (info) || sdyn->size == 0) PUT_WORD (dynobj, 0, s->contents); else PUT_WORD (dynobj, sdyn->output_section->vma + sdyn->output_offset, |