/* ELF linking support for BFD.
- Copyright (C) 1995-2016 Free Software Foundation, Inc.
+ Copyright (C) 1995-2017 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
struct elf_link_hash_table *htab = elf_hash_table (info);
/* This function may be called more than once. */
- s = bfd_get_linker_section (abfd, ".got");
- if (s != NULL)
+ if (htab->sgot != NULL)
return TRUE;
flags = bed->dynamic_sec_flags;
(SEC_ALLOC | SEC_LINKER_CREATED));
if (s == NULL)
return FALSE;
+ htab->sdynbss = s;
+
+ if (bed->want_dynrelro)
+ {
+ /* Similarly, but for symbols that were originally in read-only
+ sections. */
+ s = bfd_make_section_anyway_with_flags (abfd, ".data.rel.ro",
+ (SEC_ALLOC | SEC_READONLY
+ | SEC_HAS_CONTENTS
+ | SEC_LINKER_CREATED));
+ if (s == NULL)
+ return FALSE;
+ htab->sdynrelro = s;
+ }
/* The .rel[a].bss section holds copy relocs. This section is not
normally needed. We need to create it here, though, so that the
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 (! bfd_link_pic (info))
+ if (bfd_link_executable (info))
{
s = bfd_make_section_anyway_with_flags (abfd,
(bed->rela_plts_and_copies_p
if (s == NULL
|| ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
return FALSE;
+ htab->srelbss = s;
+
+ if (bed->want_dynrelro)
+ {
+ s = (bfd_make_section_anyway_with_flags
+ (abfd, (bed->rela_plts_and_copies_p
+ ? ".rela.data.rel.ro" : ".rel.data.rel.ro"),
+ flags | SEC_READONLY));
+ if (s == NULL
+ || ! bfd_set_section_alignment (abfd, s,
+ bed->s->log_file_align))
+ return FALSE;
+ htab->sreldynrelro = s;
+ }
}
}
if (h == NULL)
return provide;
+ if (h->root.type == bfd_link_hash_warning)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
if (h->versioned == unknown)
{
/* Set versioned if symbol version is unknown. */
hv->root.u.i.link = (struct bfd_link_hash_entry *) h;
(*bed->elf_backend_copy_indirect_symbol) (info, h, hv);
break;
- case bfd_link_hash_warning:
- abort ();
- break;
+ default:
+ BFD_FAIL ();
+ return FALSE;
}
/* If this symbol is being provided by the linker script, and it is
if (tdef && ntdef)
_bfd_error_handler
+ /* xgettext:c-format */
(_("%s: TLS definition in %B section %A "
"mismatches non-TLS definition in %B section %A"),
tbfd, tsec, ntbfd, ntsec, h->root.root.string);
else if (!tdef && !ntdef)
_bfd_error_handler
+ /* xgettext:c-format */
(_("%s: TLS reference in %B "
"mismatches non-TLS reference in %B"),
tbfd, ntbfd, h->root.root.string);
else if (tdef)
_bfd_error_handler
+ /* xgettext:c-format */
(_("%s: TLS definition in %B section %A "
"mismatches non-TLS reference in %B"),
tbfd, tsec, ntbfd, h->root.root.string);
else
_bfd_error_handler
+ /* xgettext:c-format */
(_("%s: TLS reference in %B "
"mismatches non-TLS definition in %B section %A"),
tbfd, ntbfd, ntsec, h->root.root.string);
if (hi->root.type != bfd_link_hash_defined
&& hi->root.type != bfd_link_hash_defweak)
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: unexpected redefinition of indirect versioned symbol `%s'"),
abfd, shortname);
}
/* We could not find the version for a symbol when
generating a shared archive. Return an error. */
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: version node not found for symbol %s"),
info->output_bfd, h->root.root.string);
bfd_set_error (bfd_error_bad_value);
if ((size_t) r_symndx >= nsyms)
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: bad reloc symbol index (0x%lx >= 0x%lx)"
" for offset 0x%lx in section `%A'"),
abfd, sec,
else if (r_symndx != STN_UNDEF)
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: non-zero symbol index (0x%lx) for offset 0x%lx in section `%A'"
" when the object file has no symbol table"),
abfd, sec,
else
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: relocation size mismatch in %B section %A"),
output_bfd, input_section->owner, input_section);
bfd_set_error (bfd_error_wrong_format);
&& (h->root.u.def.section->owner->flags & (DYNAMIC | BFD_PLUGIN)) == 0)
h->def_regular = 1;
+ /* If a weak undefined symbol has non-default visibility, we also
+ hide it from the dynamic linker. */
+ if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+ && h->root.type == bfd_link_hash_undefweak)
+ (*bed->elf_backend_hide_symbol) (eif->info, h, TRUE);
+
+ /* A hidden versioned symbol in executable should be forced local if
+ it is is locally defined, not referenced by shared library and not
+ exported. */
+ else if (bfd_link_executable (eif->info)
+ && h->versioned == versioned_hidden
+ && !eif->info->export_dynamic
+ && !h->dynamic
+ && !h->ref_dynamic
+ && h->def_regular)
+ (*bed->elf_backend_hide_symbol) (eif->info, h, TRUE);
+
/* If -Bsymbolic was used (which means to bind references to global
symbols to the definition within the shared object), and this
symbol was defined in a regular object, then it actually doesn't
need a PLT entry. Likewise, if the symbol has non-default
visibility. If the symbol has hidden or internal visibility, we
will force it local. */
- if (h->needs_plt
- && bfd_link_pic (eif->info)
- && is_elf_hash_table (eif->info->hash)
- && (SYMBOLIC_BIND (eif->info, h)
- || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
- && h->def_regular)
+ else if (h->needs_plt
+ && bfd_link_pic (eif->info)
+ && is_elf_hash_table (eif->info->hash)
+ && (SYMBOLIC_BIND (eif->info, h)
+ || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+ && h->def_regular)
{
bfd_boolean force_local;
(*bed->elf_backend_hide_symbol) (eif->info, h, force_local);
}
- /* If a weak undefined symbol has non-default visibility, we also
- hide it from the dynamic linker. */
- if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
- && h->root.type == bfd_link_hash_undefweak)
- (*bed->elf_backend_hide_symbol) (eif->info, h, TRUE);
-
/* If this is a weak defined symbol in a dynamic object, and we know
the real definition in the dynamic object, copy interesting flags
over to the real definition. */
|| (bed->elf_machine_alt2 != 0
&& ehdr->e_machine == bed->elf_machine_alt2)))
info->callbacks->einfo
+ /* xgettext:c-format */
(_("%P: alternate ELF machine code found (%d) in %B, expecting %d\n"),
ehdr->e_machine, abfd, bed->elf_machine_code);
const char *soname = NULL;
char *audit = NULL;
struct bfd_link_needed_list *rpath = NULL, *runpath = NULL;
+ const Elf_Internal_Phdr *phdr;
int ret;
/* ld --just-symbols and dynamic objects don't mix very well.
*pn = rpath;
}
+ /* If we have a PT_GNU_RELRO program header, mark as read-only
+ all sections contained fully therein. This makes relro
+ shared library sections appear as they will at run-time. */
+ phdr = elf_tdata (abfd)->phdr + elf_elfheader (abfd)->e_phnum;
+ while (--phdr >= elf_tdata (abfd)->phdr)
+ if (phdr->p_type == PT_GNU_RELRO)
+ {
+ for (s = abfd->sections; s != NULL; s = s->next)
+ if ((s->flags & SEC_ALLOC) != 0
+ && s->vma >= phdr->p_vaddr
+ && s->vma + s->size <= phdr->p_vaddr + phdr->p_memsz)
+ s->flags |= SEC_READONLY;
+ break;
+ }
+
/* We do not want to include any of the sections in a dynamic
object in the output file. We hack by simply clobbering the
list of sections in the BFD. This could be handled more
if (verstr == NULL)
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: %s: invalid version %u (max %d)"),
abfd, name, vernum,
elf_tdata (abfd)->cverdefs);
if (verstr == NULL)
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: %s: invalid needed version %d"),
abfd, name, vernum);
bfd_set_error (bfd_error_bad_value);
/* PR binutils/2735 */
if (normal_bfd == NULL)
_bfd_error_handler
+ /* xgettext:c-format */
(_("Warning: alignment %u of common symbol `%s' in %B is"
" greater than the alignment (%u) of its section %A"),
common_bfd, h->root.u.def.section,
1 << common_align, name, 1 << normal_align);
else
_bfd_error_handler
+ /* xgettext:c-format */
(_("Warning: alignment %u of symbol `%s' in %B"
" is smaller than %u in %B"),
normal_bfd, common_bfd,
&& h->size != isym->st_size
&& ! size_change_ok)
_bfd_error_handler
+ /* xgettext:c-format */
(_("Warning: size of symbol `%s' changed"
" from %lu in %B to %lu in %B"),
old_bfd, abfd,
if (h->type != type)
{
if (h->type != STT_NOTYPE && ! type_change_ok)
+ /* xgettext:c-format */
_bfd_error_handler
(_("Warning: type of symbol `%s' changed"
" from %d to %d in %B"),
&& (elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0)
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: undefined reference to symbol '%s'"),
old_bfd, name);
bfd_set_error (bfd_error_missing_dso);
/* The symbol has no type if specified on the command line. */
h->type = STT_OBJECT;
if (info->stacksize)
+ /* xgettext:c-format */
_bfd_error_handler (_("%B: stack size specified and %s set"),
output_bfd, legacy_symbol);
else if (h->root.u.def.section != bfd_abs_section_ptr)
+ /* xgettext:c-format */
_bfd_error_handler (_("%B: %s not absolute"),
output_bfd, legacy_symbol);
else
struct elf_link_hash_table *htab;
/* Copy down any references that we may have already seen to the
- symbol which just became indirect if DIR isn't a hidden versioned
- symbol. */
+ symbol which just became indirect. */
if (dir->versioned != versioned_hidden)
- {
- dir->ref_dynamic |= ind->ref_dynamic;
- dir->ref_regular |= ind->ref_regular;
- dir->ref_regular_nonweak |= ind->ref_regular_nonweak;
- dir->non_got_ref |= ind->non_got_ref;
- dir->needs_plt |= ind->needs_plt;
- dir->pointer_equality_needed |= ind->pointer_equality_needed;
- }
+ dir->ref_dynamic |= ind->ref_dynamic;
+ dir->ref_regular |= ind->ref_regular;
+ dir->ref_regular_nonweak |= ind->ref_regular_nonweak;
+ dir->non_got_ref |= ind->non_got_ref;
+ dir->needs_plt |= ind->needs_plt;
+ dir->pointer_equality_needed |= ind->pointer_equality_needed;
if (ind->root.type != bfd_link_hash_indirect)
return;
static void
undefined_reference (const char *reftype, const char *name)
{
+ /* xgettext:c-format */
_bfd_error_handler (_("undefined %s reference in complex symbol: %s"),
reftype, name);
}
/* The gABI doesn't support dynamic symbols in output sections
beyond 64k. */
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: Too many sections: %d (>= %d)"),
abfd, bfd_count_sections (abfd), SHN_LORESERVE & 0xffff);
bfd_set_error (bfd_error_nonrepresentable_section);
long indx;
int ret;
unsigned int type;
- /* A symbol is bound locally if it is forced local or it is locally
- defined, hidden versioned, not referenced by shared library and
- not exported when linking executable. */
- bfd_boolean local_bind = (h->forced_local
- || (bfd_link_executable (flinfo->info)
- && !flinfo->info->export_dynamic
- && !h->dynamic
- && !h->ref_dynamic
- && h->def_regular
- && h->versioned == versioned_hidden));
if (h->root.type == bfd_link_hash_warning)
{
/* Decide whether to output this symbol in this pass. */
if (eoinfo->localsyms)
{
- if (!local_bind)
+ if (!h->forced_local)
return TRUE;
}
else
{
- if (local_bind)
+ if (h->forced_local)
return TRUE;
}
hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL)
+ /* xgettext:c-format */
msg = _("%B: internal symbol `%s' in %B is referenced by DSO");
else if (ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
+ /* xgettext:c-format */
msg = _("%B: hidden symbol `%s' in %B is referenced by DSO");
else
+ /* xgettext:c-format */
msg = _("%B: local symbol `%s' in %B is referenced by DSO");
def_bfd = flinfo->output_bfd;
if (hi->root.u.def.section != bfd_abs_section_ptr)
if (sym.st_shndx == SHN_BAD)
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: could not find output section %A for input section %A"),
flinfo->output_bfd, input_sec->output_section, input_sec);
bfd_set_error (bfd_error_nonrepresentable_section);
abort ();
}
- if (local_bind)
+ if (h->forced_local)
{
sym.st_info = ELF_ST_INFO (STB_LOCAL, type);
/* Turn off visibility on local symbol. */
const char *msg;
if (ELF_ST_VISIBILITY (sym.st_other) == STV_PROTECTED)
+ /* xgettext:c-format */
msg = _("%B: protected symbol `%s' isn't defined");
else if (ELF_ST_VISIBILITY (sym.st_other) == STV_INTERNAL)
+ /* xgettext:c-format */
msg = _("%B: internal symbol `%s' isn't defined");
else
+ /* xgettext:c-format */
msg = _("%B: hidden symbol `%s' isn't defined");
_bfd_error_handler (msg, flinfo->output_bfd, h->root.root.string);
bfd_set_error (bfd_error_bad_value);
/* Since there is no version information in the dynamic string,
if there is no version info in symbol version section, we will
have a run-time problem if not linking executable, referenced
- by shared library, not locally defined, or not bound locally.
- */
+ by shared library, or not bound locally. */
if (h->verinfo.verdef == NULL
- && !local_bind
&& (!bfd_link_executable (flinfo->info)
|| h->ref_dynamic
|| !h->def_regular))
if (p && p [1] != '\0')
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: No symbol version section for versioned symbol `%s'"),
flinfo->output_bfd, h->root.root.string);
eoinfo->failed = TRUE;
if (o->size != o->reloc_count * address_size)
{
_bfd_error_handler
+ /* xgettext:c-format */
(_("error: %B: size of section %A is not "
"multiple of address size"),
input_bfd, o);
sprintf_vma (buffer, rel->r_info);
_bfd_error_handler
+ /* xgettext:c-format */
(_("error: %B contains a reloc (0x%s) for section %A "
"that references a non-existent global symbol"),
input_bfd, o, buffer);
BFD_ASSERT (r_symndx != STN_UNDEF);
if (action_discarded & COMPLAIN)
(*flinfo->info->callbacks->einfo)
+ /* xgettext:c-format */
(_("%X`%s' referenced in section `%A' of %B: "
"defined in discarded section `%A' of %B\n"),
sym_name, o, input_bfd, sec, sec->owner);
= get_elf_backend_data (s->owner);
if (bed->link_order_error_handler)
bed->link_order_error_handler
+ /* xgettext:c-format */
(_("%B: warning: sh_link not set for section `%A'"), s->owner, s);
return 0;
}
{
if (other_sec && linkorder_sec)
_bfd_error_handler
+ /* xgettext:c-format */
(_("%A has both ordered [`%A' in %B] "
"and unordered [`%A' in %B] sections"),
o, linkorder_sec,
asection *attr_section = NULL;
bfd_vma attr_size = 0;
const char *std_attrs_section;
+ struct elf_link_hash_table *htab = elf_hash_table (info);
- if (! is_elf_hash_table (info->hash))
+ if (!is_elf_hash_table (htab))
return FALSE;
if (bfd_link_pic (info))
abfd->flags |= DYNAMIC;
- dynamic = elf_hash_table (info)->dynamic_sections_created;
- dynobj = elf_hash_table (info)->dynobj;
+ dynamic = htab->dynamic_sections_created;
+ dynobj = htab->dynobj;
emit_relocs = (bfd_link_relocatable (info)
|| info->emitrelocations);
asection *sec;
sec = p->u.indirect.section;
- esdi = elf_section_data (sec);
/* Mark all sections which are to be included in the
link. This will normally be every section. We need
if (sec->flags & SEC_MERGE)
merged = TRUE;
- if (esdo->this_hdr.sh_type == SHT_REL
- || esdo->this_hdr.sh_type == SHT_RELA)
- /* Some backends use reloc_count in relocation sections
- to count particular types of relocs. Of course,
- reloc sections themselves can't have relocations. */
- reloc_count = 0;
- else if (emit_relocs)
- {
- reloc_count = sec->reloc_count;
- if (bed->elf_backend_count_additional_relocs)
- {
- int c;
- c = (*bed->elf_backend_count_additional_relocs) (sec);
- additional_reloc_count += c;
- }
- }
- else if (bed->elf_backend_count_relocs)
- reloc_count = (*bed->elf_backend_count_relocs) (info, sec);
-
if (sec->rawsize > max_contents_size)
max_contents_size = sec->rawsize;
if (sec->size > max_contents_size)
max_contents_size = sec->size;
- /* We are interested in just local symbols, not all
- symbols. */
if (bfd_get_flavour (sec->owner) == bfd_target_elf_flavour
&& (sec->owner->flags & DYNAMIC) == 0)
{
size_t sym_count;
+ /* We are interested in just local symbols, not all
+ symbols. */
if (elf_bad_symtab (sec->owner))
sym_count = (elf_tdata (sec->owner)->symtab_hdr.sh_size
/ bed->s->sizeof_sym);
&& elf_symtab_shndx_list (sec->owner) != NULL)
max_sym_shndx_count = sym_count;
+ if (esdo->this_hdr.sh_type == SHT_REL
+ || esdo->this_hdr.sh_type == SHT_RELA)
+ /* Some backends use reloc_count in relocation sections
+ to count particular types of relocs. Of course,
+ reloc sections themselves can't have relocations. */
+ ;
+ else if (emit_relocs)
+ {
+ reloc_count = sec->reloc_count;
+ if (bed->elf_backend_count_additional_relocs)
+ {
+ int c;
+ c = (*bed->elf_backend_count_additional_relocs) (sec);
+ additional_reloc_count += c;
+ }
+ }
+ else if (bed->elf_backend_count_relocs)
+ reloc_count = (*bed->elf_backend_count_relocs) (info, sec);
+
+ esdi = elf_section_data (sec);
+
if ((sec->flags & SEC_RELOC) != 0)
{
size_t ext_size = 0;
}
if (! bfd_link_relocatable (info) && merged)
- elf_link_hash_traverse (elf_hash_table (info),
- _bfd_elf_link_sec_merge_syms, abfd);
+ elf_link_hash_traverse (htab, _bfd_elf_link_sec_merge_syms, abfd);
/* Figure out the file positions for everything but the symbol table
and the relocs. We set symcount to force assign_section_numbers
if (max_sym_count < 20)
max_sym_count = 20;
- elf_hash_table (info)->strtabsize = max_sym_count;
+ htab->strtabsize = max_sym_count;
amt = max_sym_count * sizeof (struct elf_sym_strtab);
- elf_hash_table (info)->strtab
- = (struct elf_sym_strtab *) bfd_malloc (amt);
- if (elf_hash_table (info)->strtab == NULL)
+ htab->strtab = (struct elf_sym_strtab *) bfd_malloc (amt);
+ if (htab->strtab == NULL)
goto error_return;
/* The real buffer will be allocated in elf_link_swap_symbols_out. */
flinfo.symshndxbuf
goto error_return;
}
- if (elf_hash_table (info)->tls_sec)
+ if (htab->tls_sec)
{
bfd_vma base, end = 0;
asection *sec;
- for (sec = elf_hash_table (info)->tls_sec;
+ for (sec = htab->tls_sec;
sec && (sec->flags & SEC_THREAD_LOCAL);
sec = sec->next)
{
}
end = sec->vma + size;
}
- base = elf_hash_table (info)->tls_sec->vma;
+ base = htab->tls_sec->vma;
/* Only align end of TLS section if static TLS doesn't have special
alignment requirements. */
if (bed->static_tls_alignment == 1)
- end = align_power (end,
- elf_hash_table (info)->tls_sec->alignment_power);
- elf_hash_table (info)->tls_size = end - base;
+ end = align_power (end, htab->tls_sec->alignment_power);
+ htab->tls_size = end - base;
}
/* Reorder SHF_LINK_ORDER sections. */
bfd_set_error (bfd_error_wrong_format);
_bfd_error_handler
+ /* xgettext:c-format */
(_("%B: file class %s incompatible with %s"),
sub, iclass, oclass);
}
symtab_hdr->sh_info = bfd_get_symcount (abfd);
if (dynamic
- && elf_hash_table (info)->dynsym != NULL
- && (elf_hash_table (info)->dynsym->output_section
- != bfd_abs_section_ptr))
+ && htab->dynsym != NULL
+ && htab->dynsym->output_section != bfd_abs_section_ptr)
{
Elf_Internal_Sym sym;
- bfd_byte *dynsym = elf_hash_table (info)->dynsym->contents;
+ bfd_byte *dynsym = htab->dynsym->contents;
- o = elf_hash_table (info)->dynsym->output_section;
- elf_section_data (o)->this_hdr.sh_info
- = elf_hash_table (info)->local_dynsymcount + 1;
+ o = htab->dynsym->output_section;
+ elf_section_data (o)->this_hdr.sh_info = htab->local_dynsymcount + 1;
/* Write out the section symbols for the output sections. */
if (bfd_link_pic (info)
- || elf_hash_table (info)->is_relocatable_executable)
+ || htab->is_relocatable_executable)
{
asection *s;
}
/* Write out the local dynsyms. */
- if (elf_hash_table (info)->dynlocal)
+ if (htab->dynlocal)
{
struct elf_link_local_dynamic_entry *e;
- for (e = elf_hash_table (info)->dynlocal; e ; e = e->next)
+ for (e = htab->dynlocal; e ; e = e->next)
{
asection *s;
bfd_byte *dest;
{
struct elf_link_hash_entry *h;
- h = elf_link_hash_lookup (elf_hash_table (info), name,
- FALSE, FALSE, TRUE);
+ h = elf_link_hash_lookup (htab, name, FALSE, FALSE, TRUE);
if (h != NULL
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak))
}
}
}
+ if (bed->dtrel_excludes_plt && htab->srelplt != NULL)
+ {
+ /* Don't count procedure linkage table relocs in the
+ overall reloc count. */
+ if (dyn.d_tag == DT_RELSZ || dyn.d_tag == DT_RELASZ)
+ dyn.d_un.d_val -= htab->srelplt->size;
+ /* If .rela.plt is the first .rela section, exclude
+ it from DT_RELA. */
+ else if (dyn.d_un.d_ptr == (htab->srelplt->output_section->vma
+ + htab->srelplt->output_offset))
+ dyn.d_un.d_ptr += htab->srelplt->size;
+ }
break;
}
bed->s->swap_dyn_out (dynobj, &dyn, dyncon);
created by _bfd_elf_link_create_dynamic_sections. */
continue;
}
- if (elf_hash_table (info)->stab_info.stabstr == o)
+ if (htab->stab_info.stabstr == o)
continue;
- if (elf_hash_table (info)->eh_info.hdr_sec == o)
+ if (htab->eh_info.hdr_sec == o)
continue;
if (strcmp (o->name, ".dynstr") != 0)
{
off = elf_section_data (o->output_section)->this_hdr.sh_offset;
if (bfd_seek (abfd, off, SEEK_SET) != 0
- || ! _bfd_elf_strtab_emit (abfd,
- elf_hash_table (info)->dynstr))
+ || !_bfd_elf_strtab_emit (abfd, htab->dynstr))
goto error_return;
}
}
}
/* If we have optimized stabs strings, output them. */
- if (elf_hash_table (info)->stab_info.stabstr != NULL)
+ if (htab->stab_info.stabstr != NULL)
{
- if (! _bfd_write_stab_strings (abfd, &elf_hash_table (info)->stab_info))
+ if (!_bfd_write_stab_strings (abfd, &htab->stab_info))
goto error_return;
}
o->flags |= SEC_EXCLUDE;
if (info->print_gc_sections && o->size != 0)
+ /* xgettext:c-format */
_bfd_error_handler (_("Removing unused section '%s' in file '%B'"), sub, o->name);
/* But we also have to update some of the relocation
&& ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
&& ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
&& (!bfd_link_executable (info)
+ || info->gc_keep_exported
|| info->export_dynamic
|| (h->dynamic
&& d != NULL
if (h != NULL
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
- && !bfd_is_abs_section (h->root.u.def.section))
+ && !bfd_is_abs_section (h->root.u.def.section)
+ && !bfd_is_und_section (h->root.u.def.section))
h->root.u.def.section->flags |= SEC_KEEP;
}
}
return FALSE;
/* Mark dynamically referenced symbols. */
- if (htab->dynamic_sections_created)
+ if (htab->dynamic_sections_created || info->gc_keep_exported)
elf_link_hash_traverse (htab, bed->gc_mark_dynamic_ref, info);
/* Grovel through relocs to find out who stays ... */
goto win;
}
- _bfd_error_handler ("%B: %A+%lu: No symbol found for INHERIT",
+ /* xgettext:c-format */
+ _bfd_error_handler (_("%B: %A+%lu: No symbol found for INHERIT"),
abfd, sec, (unsigned long) offset);
bfd_set_error (bfd_error_invalid_operation);
return FALSE;