aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-18 05:51:03 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-18 05:51:19 -0700
commit0e1862bb401f47716446aef143b2bf7a4563f541 (patch)
tree8410cdece79e8df2f1394b53d1e992736323baac /bfd/elflink.c
parentb2a33439909493f5bf93ada871bd588f365d61f4 (diff)
downloadgdb-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/elflink.c')
-rw-r--r--bfd/elflink.c122
1 files changed, 64 insertions, 58 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 9b93431..e4a9ced 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -246,7 +246,7 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
/* A dynamically linked executable has a .interp section, but a
shared library does not. */
- if (info->executable)
+ if (bfd_link_executable (info))
{
s = bfd_make_section_anyway_with_flags (abfd, ".interp",
flags | SEC_READONLY);
@@ -418,7 +418,7 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
be needed, we can discard it later. We will never need this
section when generating a shared object, since they do not use
copy relocs. */
- if (! info->shared)
+ if (! bfd_link_pic (info))
{
s = bfd_make_section_anyway_with_flags (abfd,
(bed->rela_plts_and_copies_p
@@ -519,7 +519,7 @@ bfd_elf_link_mark_dynamic_symbol (struct bfd_link_info *info,
struct bfd_elf_dynamic_list *d = info->dynamic_list;
/* It may be called more than once on the same H. */
- if(h->dynamic || info->relocatable)
+ if(h->dynamic || bfd_link_relocatable (info))
return;
if ((info->dynamic_data
@@ -623,7 +623,7 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
/* STV_HIDDEN and STV_INTERNAL symbols must be STB_LOCAL in shared objects
and executables. */
- if (!info->relocatable
+ if (!bfd_link_relocatable (info)
&& h->dynindx != -1
&& (ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
|| ELF_ST_VISIBILITY (h->other) == STV_INTERNAL))
@@ -631,8 +631,9 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
if ((h->def_dynamic
|| h->ref_dynamic
- || info->shared
- || (info->executable && elf_hash_table (info)->is_relocatable_executable))
+ || bfd_link_pic (info)
+ || (bfd_link_executable (info)
+ && elf_hash_table (info)->is_relocatable_executable))
&& h->dynindx == -1)
{
if (! bfd_elf_link_record_dynamic_symbol (info, h))
@@ -842,7 +843,8 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd,
{
unsigned long dynsymcount = 0;
- if (info->shared || elf_hash_table (info)->is_relocatable_executable)
+ if (bfd_link_pic (info)
+ || elf_hash_table (info)->is_relocatable_executable)
{
const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
asection *p;
@@ -1743,7 +1745,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
if (! override)
{
/* Add the default symbol if not performing a relocatable link. */
- if (! info->relocatable)
+ if (! bfd_link_relocatable (info))
{
bh = &hi->root;
if (! (_bfd_generic_link_add_one_symbol
@@ -1824,7 +1826,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
{
if (! dynamic)
{
- if (! info->executable
+ if (! bfd_link_executable (info)
|| hi->def_dynamic
|| hi->ref_dynamic)
*dynsym = TRUE;
@@ -1896,7 +1898,7 @@ nondefault:
{
if (! dynamic)
{
- if (! info->executable
+ if (! bfd_link_executable (info)
|| hi->ref_dynamic)
*dynsym = TRUE;
}
@@ -2119,7 +2121,7 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data)
/* If we are building an application, we need to create a
version node for this version. */
- if (t == NULL && info->executable)
+ if (t == NULL && bfd_link_executable (info))
{
struct bfd_elf_version_tree **pp;
int version_index;
@@ -2481,7 +2483,7 @@ bfd_boolean
_bfd_elf_link_hash_fixup_symbol (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
- if (info->pie
+ if (bfd_link_pie (info)
&& h->dynindx == -1
&& h->root.type == bfd_link_hash_undefweak)
return bfd_elf_link_record_dynamic_symbol (info, h);
@@ -2584,7 +2586,7 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h,
visibility. If the symbol has hidden or internal visibility, we
will force it local. */
if (h->needs_plt
- && eif->info->shared
+ && bfd_link_pic (eif->info)
&& is_elf_hash_table (eif->info->hash)
&& (SYMBOLIC_BIND (eif->info, h)
|| ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
@@ -2856,7 +2858,8 @@ _bfd_elf_dynamic_symbol_p (struct elf_link_hash_entry *h,
/* Identify the cases where name binding rules say that a
visible symbol resolves locally. */
- binding_stays_local_p = info->executable || SYMBOLIC_BIND (info, h);
+ binding_stays_local_p = (bfd_link_executable (info)
+ || SYMBOLIC_BIND (info, h));
switch (ELF_ST_VISIBILITY (h->other))
{
@@ -2941,7 +2944,7 @@ _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *h,
/* At this point, we know the symbol is defined and dynamic. In an
executable it must resolve locally, likewise when building symbolic
shared libraries. */
- if (info->executable || SYMBOLIC_BIND (info, h))
+ if (bfd_link_executable (info) || SYMBOLIC_BIND (info, h))
return TRUE;
/* Now deal with defined dynamic symbols in shared libraries. Ones
@@ -3488,11 +3491,11 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
/* You can't use -r against a dynamic object. Also, there's no
hope of using a dynamic object which does not exactly match
the format of the output file. */
- if (info->relocatable
+ if (bfd_link_relocatable (info)
|| !is_elf_hash_table (htab)
|| info->output_bfd->xvec != abfd->xvec)
{
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
bfd_set_error (bfd_error_invalid_operation);
else
bfd_set_error (bfd_error_wrong_format);
@@ -3565,7 +3568,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
FALSE, bed->collect, NULL)))
goto error_return;
- if (info->executable)
+ if (bfd_link_executable (info))
{
/* Clobber the section size so that the warning does
not get copied into the output file. */
@@ -3591,7 +3594,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
are no input BFD's of the same format as the output, we can't
make a shared library. */
if (!just_syms
- && info->shared
+ && bfd_link_pic (info)
&& is_elf_hash_table (htab)
&& info->output_bfd->xvec == abfd->xvec
&& !htab->dynamic_sections_created)
@@ -4043,7 +4046,7 @@ error_free_dyn:
}
else if (isym->st_shndx == SHN_COMMON
&& ELF_ST_TYPE (isym->st_info) == STT_TLS
- && !info->relocatable)
+ && !bfd_link_relocatable (info))
{
asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon");
@@ -4339,7 +4342,7 @@ error_free_dyn:
/* If the indirect symbol has been forced local, don't
make the real symbol dynamic. */
if ((h == hi || !hi->forced_local)
- && ((! info->executable && ! info->relocatable)
+ && (bfd_link_dll (info)
|| h->def_dynamic
|| h->ref_dynamic))
dynsym = TRUE;
@@ -4491,7 +4494,9 @@ error_free_dyn:
elf_merge_st_other (abfd, h, isym, sec, definition, dynamic);
/* We don't want to make debug symbol dynamic. */
- if (definition && (sec->flags & SEC_DEBUGGING) && !info->relocatable)
+ if (definition
+ && (sec->flags & SEC_DEBUGGING)
+ && !bfd_link_relocatable (info))
dynsym = FALSE;
/* Nor should we make plugin symbols dynamic. */
@@ -4694,7 +4699,7 @@ error_free_dyn:
/* Now that all the symbols from this input file are created, if
not performing a relocatable link, handle .symver foo, foo@BAR
such that any relocs against foo become foo@BAR. */
- if (!info->relocatable && nondeflt_vers != NULL)
+ if (!bfd_link_relocatable (info) && nondeflt_vers != NULL)
{
bfd_size_type cnt, symidx;
@@ -5696,7 +5701,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
elf_hash_table (info)->init_plt_refcount
= elf_hash_table (info)->init_plt_offset;
- if (info->relocatable
+ if (bfd_link_relocatable (info)
&& !_bfd_elf_size_group_sections (info))
return FALSE;
@@ -5739,7 +5744,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
}
if (notesec || info->stacksize > 0)
elf_stack_flags (output_bfd) = PF_R | PF_W | exec;
- if (notesec && exec && info->relocatable
+ if (notesec && exec && bfd_link_relocatable (info)
&& notesec->output_section != bfd_abs_section_ptr)
notesec->output_section->flags |= SEC_CODE;
}
@@ -5757,7 +5762,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
bfd_boolean all_defined;
*sinterpptr = bfd_get_linker_section (dynobj, ".interp");
- BFD_ASSERT (*sinterpptr != NULL || !info->executable);
+ BFD_ASSERT (*sinterpptr != NULL || !bfd_link_executable (info));
if (soname != NULL)
{
@@ -5845,7 +5850,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
/* If we are supposed to export all symbols into the dynamic symbol
table (this is not the normal case), then do so. */
if (info->export_dynamic
- || (info->executable && info->dynamic))
+ || (bfd_link_executable (info) && info->dynamic))
{
elf_link_hash_traverse (elf_hash_table (info),
_bfd_elf_export_symbol,
@@ -5980,7 +5985,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
if (s != NULL && s->linker_has_input)
{
/* DT_PREINIT_ARRAY is not allowed in shared library. */
- if (! info->executable)
+ if (! bfd_link_executable (info))
{
bfd *sub;
asection *o;
@@ -6314,7 +6319,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd,
if (info->flags_1)
{
- if (info->executable)
+ if (bfd_link_executable (info))
info->flags_1 &= ~ (DF_1_INITFIRST
| DF_1_NODELETE
| DF_1_NOOPEN);
@@ -8993,7 +8998,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
defined, hidden versioned, not referenced by shared library and
not exported when linking executable. */
bfd_boolean local_bind = (h->forced_local
- || (flinfo->info->executable
+ || (bfd_link_executable (flinfo->info)
&& !flinfo->info->export_dynamic
&& !h->dynamic
&& !h->ref_dynamic
@@ -9058,7 +9063,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
/* We should also warn if a forced local symbol is referenced from
shared libraries. */
- if (flinfo->info->executable
+ if (bfd_link_executable (flinfo->info)
&& h->forced_local
&& h->ref_dynamic
&& h->def_regular
@@ -9189,7 +9194,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
but in nonrelocatable files they are virtual
addresses. */
sym.st_value = h->root.u.def.value + input_sec->output_offset;
- if (!flinfo->info->relocatable)
+ if (!bfd_link_relocatable (flinfo->info))
{
sym.st_value += input_sec->output_section->vma;
if (h->type == STT_TLS)
@@ -9233,10 +9238,10 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
STT_GNU_IFUNC symbol must go through PLT. */
if ((h->type == STT_GNU_IFUNC
&& h->def_regular
- && !flinfo->info->relocatable)
+ && !bfd_link_relocatable (flinfo->info))
|| ((h->dynindx != -1
|| h->forced_local)
- && ((flinfo->info->shared
+ && ((bfd_link_pic (flinfo->info)
&& (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
|| h->root.type != bfd_link_hash_undefweak))
|| !h->forced_local)
@@ -9286,7 +9291,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
/* If a non-weak symbol with non-default visibility is not defined
locally, it is a fatal error. */
- if (!flinfo->info->relocatable
+ if (!bfd_link_relocatable (flinfo->info)
&& ELF_ST_VISIBILITY (sym.st_other) != STV_DEFAULT
&& ELF_ST_BIND (sym.st_info) != STB_WEAK
&& h->root.type == bfd_link_hash_undefined
@@ -9322,7 +9327,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
*/
if (h->verinfo.verdef == NULL
&& !local_bind
- && (!flinfo->info->executable
+ && (!bfd_link_executable (flinfo->info)
|| h->ref_dynamic
|| !h->def_regular))
{
@@ -9410,7 +9415,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
relocatable output or when needed for --emit-relocs. */
else if (input_sec == bfd_und_section_ptr
&& h->indx != -2
- && !flinfo->info->relocatable)
+ && !bfd_link_relocatable (flinfo->info))
return TRUE;
/* Also strip others that we couldn't earlier due to dynamic symbol
processing. */
@@ -9711,7 +9716,8 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
&& (bfd_hash_lookup (flinfo->info->keep_hash, name, FALSE, FALSE)
== NULL))
|| (((flinfo->info->discard == discard_sec_merge
- && (isec->flags & SEC_MERGE) && !flinfo->info->relocatable)
+ && (isec->flags & SEC_MERGE)
+ && !bfd_link_relocatable (flinfo->info))
|| flinfo->info->discard == discard_l)
&& bfd_is_local_label_name (input_bfd, name)))
continue;
@@ -9762,7 +9768,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
output_section. Any special sections must be set up to meet
these requirements. */
osym.st_value += isec->output_offset;
- if (!flinfo->info->relocatable)
+ if (!bfd_link_relocatable (flinfo->info))
{
osym.st_value += isec->output_section->vma;
if (ELF_ST_TYPE (osym.st_info) == STT_TLS)
@@ -9806,7 +9812,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
continue;
}
- if (flinfo->info->relocatable
+ if (bfd_link_relocatable (flinfo->info)
&& (o->flags & (SEC_LINKER_CREATED | SEC_GROUP)) == SEC_GROUP)
{
/* Deal with the group signature symbol. */
@@ -10029,7 +10035,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
}
if ((s_type == STT_RELC || s_type == STT_SRELC)
- && !flinfo->info->relocatable)
+ && !bfd_link_relocatable (flinfo->info))
{
bfd_vma val;
bfd_vma dot = (rel->r_offset
@@ -10119,7 +10125,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
return FALSE;
if (ret == 2
- || flinfo->info->relocatable
+ || bfd_link_relocatable (flinfo->info)
|| flinfo->info->emitrelocations)
{
Elf_Internal_Rela *irela;
@@ -10150,7 +10156,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
rel_hash_list = rel_hash;
rela_hash_list = NULL;
last_offset = o->output_offset;
- if (!flinfo->info->relocatable)
+ if (!bfd_link_relocatable (flinfo->info))
last_offset += o->output_section->vma;
for (next_erel = 0; irela < irelaend; irela++, next_erel++)
{
@@ -10190,7 +10196,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
irela->r_offset += o->output_offset;
/* Relocs in an executable have to be virtual addresses. */
- if (!flinfo->info->relocatable)
+ if (!bfd_link_relocatable (flinfo->info))
irela->r_offset += o->output_section->vma;
last_offset = irela->r_offset;
@@ -10318,7 +10324,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
return FALSE;
sym.st_value += sec->output_offset;
- if (!flinfo->info->relocatable)
+ if (!bfd_link_relocatable (flinfo->info))
{
sym.st_value += osec->vma;
if (ELF_ST_TYPE (sym.st_info) == STT_TLS)
@@ -10594,7 +10600,7 @@ elf_reloc_link_order (bfd *output_bfd,
relocatable file, and is a virtual address in an executable
file. */
offset = link_order->offset;
- if (! info->relocatable)
+ if (! bfd_link_relocatable (info))
offset += output_section->vma;
for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
@@ -10845,13 +10851,13 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
if (! is_elf_hash_table (info->hash))
return FALSE;
- if (info->shared)
+ if (bfd_link_pic (info))
abfd->flags |= DYNAMIC;
dynamic = elf_hash_table (info)->dynamic_sections_created;
dynobj = elf_hash_table (info)->dynobj;
- emit_relocs = (info->relocatable
+ emit_relocs = (bfd_link_relocatable (info)
|| info->emitrelocations);
flinfo.info = info;
@@ -10964,7 +10970,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
to count particular types of relocs. Of course,
reloc sections themselves can't have relocations. */
reloc_count = 0;
- else if (info->relocatable || info->emitrelocations)
+ else if (emit_relocs)
reloc_count = sec->reloc_count;
else if (bed->elf_backend_count_relocs)
reloc_count = (*bed->elf_backend_count_relocs) (info, sec);
@@ -11016,8 +11022,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
o->reloc_count += reloc_count;
- if (p->type == bfd_indirect_link_order
- && (info->relocatable || info->emitrelocations))
+ if (p->type == bfd_indirect_link_order && emit_relocs)
{
if (esdi->rel.hdr)
esdo->rel.count += NUM_SHDR_ENTRIES (esdi->rel.hdr);
@@ -11052,7 +11057,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
o->vma = 0;
}
- if (! info->relocatable && merged)
+ if (! bfd_link_relocatable (info) && merged)
elf_link_hash_traverse (elf_hash_table (info),
_bfd_elf_link_sec_merge_syms, abfd);
@@ -11168,7 +11173,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
{
o->target_index = bfd_get_symcount (abfd);
elfsym.st_shndx = i;
- if (!info->relocatable)
+ if (!bfd_link_relocatable (info))
elfsym.st_value = o->vma;
if (elf_link_output_symstrtab (&flinfo, NULL, &elfsym, o,
NULL) != 1)
@@ -11410,7 +11415,8 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
long last_local = 0;
/* Write out the section symbols for the output sections. */
- if (info->shared || elf_hash_table (info)->is_relocatable_executable)
+ if (bfd_link_pic (info)
+ || elf_hash_table (info)->is_relocatable_executable)
{
asection *s;
@@ -11761,7 +11767,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
goto error_return;
/* Check for DT_TEXTREL (late, in case the backend removes it). */
- if (((info->warn_shared_textrel && info->shared)
+ if (((info->warn_shared_textrel && bfd_link_pic (info))
|| info->error_textrel)
&& (o = bfd_get_linker_section (dynobj, ".dynamic")) != NULL)
{
@@ -11828,7 +11834,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
}
}
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
{
bfd_boolean failed = FALSE;
@@ -12571,7 +12577,7 @@ bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
|| ((h->def_regular || ELF_COMMON_DEF_P (h))
&& ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
&& ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
- && (!info->executable
+ && (!bfd_link_executable (info)
|| info->export_dynamic
|| (h->dynamic
&& d != NULL
@@ -13220,7 +13226,7 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
_bfd_elf_end_eh_frame_parsing (info);
if (info->eh_frame_hdr_type
- && !info->relocatable
+ && !bfd_link_relocatable (info)
&& _bfd_elf_discard_section_eh_frame_hdr (output_bfd, info))
changed = 1;