/* We also need to define an indirection from the nondefault version
of the symbol. */
-nondefault:
+ nondefault:
len = strlen (name);
shortname = (char *) bfd_hash_allocate (&info->hash->table, len);
if (shortname == NULL)
elf_hash_table (info)->tls_sec = tls;
- /* Ensure the alignment of the first section is the largest alignment,
- so that the tls segment starts aligned. */
+ /* Ensure the alignment of the first section (usually .tdata) is the largest
+ alignment, so that the tls segment starts aligned. */
if (tls != NULL)
tls->alignment_power = align;
if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
{
-error_free_dyn:
+ error_free_dyn:
free (dynbuf);
goto error_return;
}
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;
+ {
+ unsigned int opb = bfd_octets_per_byte (abfd, s);
+
+ if ((s->flags & SEC_ALLOC) != 0
+ && s->vma * opb >= phdr->p_vaddr
+ && s->vma * opb + s->size <= phdr->p_vaddr + phdr->p_memsz)
+ s->flags |= SEC_READONLY;
+ }
break;
}
result = TRUE;
-done:
+ done:
if (symtable1)
free (symtable1);
if (symtable2)
&& (!h->ref_regular || flinfo->info->gc_sections)
&& !elf_link_check_versioned_symbol (flinfo->info, bed, h)
&& flinfo->info->unresolved_syms_in_shared_libs != RM_IGNORE)
- (*flinfo->info->callbacks->undefined_symbol)
- (flinfo->info, h->root.root.string,
- h->ref_regular ? NULL : h->root.u.undef.abfd,
- NULL, 0,
- flinfo->info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR);
+ {
+ flinfo->info->callbacks->undefined_symbol
+ (flinfo->info, h->root.root.string,
+ h->ref_regular ? NULL : h->root.u.undef.abfd, NULL, 0,
+ flinfo->info->unresolved_syms_in_shared_libs == RM_DIAGNOSE
+ && !flinfo->info->warn_unresolved_syms);
+ }
/* Strip a global symbol defined in a discarded section. */
if (h->indx == -3)
/* If this symbol is defined in a section which we are
discarding, we don't need to keep it. */
+ if (isym->st_shndx != SHN_UNDEF
+ && isym->st_shndx < SHN_LORESERVE
+ && isec->output_section == NULL
+ && flinfo->info->non_contiguous_regions
+ && flinfo->info->non_contiguous_regions_warnings)
+ {
+ _bfd_error_handler (_("warning: --enable-non-contiguous-regions "
+ "discards section `%s' from '%s'\n"),
+ isec->name, isec->owner->filename);
+ continue;
+ }
+
if (isym->st_shndx != SHN_UNDEF
&& isym->st_shndx < SHN_LORESERVE
&& bfd_section_removed_from_list (output_bfd,
struct bfd_link_order *p;
bfd *sub;
struct bfd_link_order **sections;
- asection *s, *other_sec, *linkorder_sec;
- bfd_vma offset;
+ asection *other_sec, *linkorder_sec;
+ bfd_vma offset; /* Octets. */
other_sec = NULL;
linkorder_sec = NULL;
{
if (p->type == bfd_indirect_link_order)
{
- s = p->u.indirect.section;
+ asection *s = p->u.indirect.section;
sub = s->owner;
if ((s->flags & SEC_LINKER_CREATED) == 0
&& bfd_get_flavour (sub) == bfd_target_elf_flavour
for (n = 0; n < seen_linkorder; n++)
{
bfd_vma mask;
- s = sections[n]->u.indirect.section;
- mask = ~(bfd_vma) 0 << s->alignment_power;
+ asection *s = sections[n]->u.indirect.section;
+ unsigned int opb = bfd_octets_per_byte (abfd, s);
+
+ mask = ~(bfd_vma) 0 << s->alignment_power * opb;
offset = (offset + ~mask) & mask;
- s->output_offset = offset / bfd_octets_per_byte (abfd, s);
- sections[n]->offset = offset;
+ sections[n]->offset = s->output_offset = offset / opb;
offset += sections[n]->size;
}
ret = TRUE;
-free_sym_buf:
+ free_sym_buf:
free (sympp);
return ret;
}
if (htab->tls_sec)
{
- bfd_vma base, end = 0;
+ bfd_vma base, end = 0; /* Both bytes. */
asection *sec;
for (sec = htab->tls_sec;
sec = sec->next)
{
bfd_size_type size = sec->size;
+ unsigned int opb = bfd_octets_per_byte (abfd, sec);
if (size == 0
&& (sec->flags & SEC_HAS_CONTENTS) == 0)
struct bfd_link_order *ord = sec->map_tail.link_order;
if (ord != NULL)
- size = ord->offset + ord->size;
+ size = ord->offset * opb + ord->size;
}
- end = sec->vma + size;
+ end = sec->vma + size / opb;
}
base = htab->tls_sec->vma;
/* Only align end of TLS section if static TLS doesn't have special
if (bed->dtrel_excludes_plt && htab->srelplt != NULL)
{
+ unsigned int opb = bfd_octets_per_byte (abfd, o);
+
/* Don't count procedure linkage table relocs in the
overall reloc count. */
sh_size -= htab->srelplt->size;
/* If .rela.plt is the first .rela section, exclude
it from DT_RELA. */
else if (sh_addr == (htab->srelplt->output_section->vma
- + htab->srelplt->output_offset))
+ + htab->srelplt->output_offset) * opb)
sh_addr += htab->srelplt->size;
}
{
asection *i;
int eh_changed = 0;
- unsigned int eh_alignment;
+ unsigned int eh_alignment; /* Octets. */
for (i = o->map_head.s; i != NULL; i = i->map_head.s)
{
fini_reloc_cookie_for_section (&cookie, i);
}
- eh_alignment = 1 << o->alignment_power;
+ eh_alignment = ((1 << o->alignment_power)
+ * bfd_octets_per_byte (output_bfd, o));
/* Skip over zero terminator, and prevent empty sections from
adding alignment padding at the end. */
for (i = o->map_tail.s; i != NULL; i = i->map_tail.s)