return elf_tdata (abfd)->core != NULL;
}
-static char *
+char *
bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)
{
Elf_Internal_Shdr **i_shdrp;
if (name == NULL)
name = "(null)";
else if (sym_sec && *name == '\0')
- name = bfd_section_name (abfd, sym_sec);
+ name = bfd_section_name (sym_sec);
return name;
}
return elf_next_in_group (sec) != NULL;
}
+const char *
+bfd_elf_group_name (bfd *abfd ATTRIBUTE_UNUSED, const asection *sec)
+{
+ if (elf_sec_group (sec) != NULL)
+ return elf_group_name (sec);
+ return NULL;
+}
+
static char *
convert_debug_to_zdebug (bfd *abfd, const char *name)
{
newsect->filepos = hdr->sh_offset;
- if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr)
- || ! bfd_set_section_size (abfd, newsect, hdr->sh_size)
- || ! bfd_set_section_alignment (abfd, newsect,
- bfd_log2 (hdr->sh_addralign)))
+ if (!bfd_set_section_vma (newsect, hdr->sh_addr)
+ || !bfd_set_section_size (newsect, hdr->sh_size)
+ || !bfd_set_section_alignment (newsect, bfd_log2 (hdr->sh_addralign)))
return FALSE;
flags = SEC_NO_FLAGS;
if (! bed->elf_backend_section_flags (&flags, hdr))
return FALSE;
- if (! bfd_set_section_flags (abfd, newsect, flags))
+ if (!bfd_set_section_flags (newsect, flags))
return FALSE;
/* We do not parse the PT_NOTE segments as we are interested even in the
char *new_name = convert_zdebug_to_debug (abfd, name);
if (new_name == NULL)
return FALSE;
- bfd_rename_section (abfd, newsect, new_name);
+ bfd_rename_section (newsect, new_name);
}
}
else
static const struct bfd_elf_special_section special_sections_c[] =
{
{ STRING_COMMA_LEN (".comment"), 0, SHT_PROGBITS, 0 },
+ { STRING_COMMA_LEN (".ctf"), 0, SHT_PROGBITS, 0 },
{ NULL, 0, 0, 0, 0 }
};
return (*bed->elf_backend_sym_is_global) (abfd, sym);
return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
- || bfd_is_und_section (bfd_get_section (sym))
- || bfd_is_com_section (bfd_get_section (sym)));
+ || bfd_is_und_section (bfd_asymbol_section (sym))
+ || bfd_is_com_section (bfd_asymbol_section (sym)));
}
/* Filter global symbols of ABFD to include in the import library. All
{
if ((s->flags & SEC_ALLOC) != 0)
{
+ /* target_index is unused until bfd_elf_final_link
+ starts output of section symbols. Use it to make
+ qsort stable. */
+ s->target_index = i;
sections[i] = s;
++i;
/* A wrapping section potentially clashes with header. */
if (TOEND (sec1))
{
- if (TOEND (sec2))
- {
- /* If the indices are the same, do not return 0
- here, but continue to try the next comparison. */
- if (sec1->target_index - sec2->target_index != 0)
- return sec1->target_index - sec2->target_index;
- }
- else
+ if (!TOEND (sec2))
return 1;
}
else if (TOEND (sec2))
if (m->count > 1
&& !(elf_elfheader (abfd)->e_type == ET_CORE
&& m->p_type == PT_NOTE))
- qsort (m->sections, (size_t) m->count, sizeof (asection *),
- elf_sort_sections);
+ {
+ for (i = 0; i < m->count; i++)
+ m->sections[i]->target_index = i;
+ qsort (m->sections, (size_t) m->count, sizeof (asection *),
+ elf_sort_sections);
+ }
/* An ELF segment (described by Elf_Internal_Phdr) may contain a
number of sections with contents contributing to both p_filesz
{
unsigned int secalign;
- secalign = bfd_get_section_alignment (abfd, *secpp);
+ secalign = bfd_section_alignment (*secpp);
if (secalign > align_power)
align_power = secalign;
}
sec = *secpp;
this_hdr = &elf_section_data (sec)->this_hdr;
- align = (bfd_size_type) 1 << bfd_get_section_alignment (abfd, sec);
+ align = (bfd_size_type) 1 << bfd_section_alignment (sec);
if ((p->p_type == PT_LOAD
|| p->p_type == PT_TLS)
return TRUE;
}
-/* Assign file positions for the other sections. */
+/* Assign file positions for the other sections, except for compressed debugging
+ and other sections assigned in _bfd_elf_assign_file_positions_for_non_load(). */
static bfd_boolean
assign_file_positions_for_non_load_sections (bfd *abfd,
}
else if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
&& hdr->bfd_section == NULL)
+ /* We don't know the offset of these sections yet: their size has
+ not been decided. */
|| (hdr->bfd_section != NULL
- && (hdr->bfd_section->flags & SEC_ELF_COMPRESS))
- /* Compress DWARF debug sections. */
+ && (hdr->bfd_section->flags & SEC_ELF_COMPRESS
+ || (bfd_section_is_ctf (hdr->bfd_section)
+ && abfd->is_linker_output)))
|| hdr == i_shdrpp[elf_onesymtab (abfd)]
|| (elf_symtab_shndx_list (abfd) != NULL
&& hdr == i_shdrpp[elf_symtab_shndx_list (abfd)->ndx])
VMAs must be known before this is called.
Reloc sections come in two flavours: Those processed specially as
- "side-channel" data attached to a section to which they apply, and
- those that bfd doesn't process as relocations. The latter sort are
- stored in a normal bfd section by bfd_section_from_shdr. We don't
- consider the former sort here, unless they form part of the loadable
- image. Reloc sections not assigned here will be handled later by
+ "side-channel" data attached to a section to which they apply, and those that
+ bfd doesn't process as relocations. The latter sort are stored in a normal
+ bfd section by bfd_section_from_shdr. We don't consider the former sort
+ here, unless they form part of the loadable image. Reloc sections not
+ assigned here (and compressed debugging sections and CTF sections which
+ nothing else in the file can rely upon) will be handled later by
assign_file_positions_for_relocs.
We also don't set the positions of the .symtab and .strtab here. */
hdr = *hdrpp;
if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
&& hdr->bfd_section == NULL)
+ /* Do not assign offsets for these sections yet: we don't know
+ their sizes. */
|| (hdr->bfd_section != NULL
- && (hdr->bfd_section->flags & SEC_ELF_COMPRESS))
- /* Compress DWARF debug sections. */
+ && (hdr->bfd_section->flags & SEC_ELF_COMPRESS
+ || (bfd_section_is_ctf (hdr->bfd_section)
+ && abfd->is_linker_output)))
|| i == elf_onesymtab (abfd)
|| (elf_symtab_shndx_list (abfd) != NULL
&& hdr == i_shdrpp[elf_symtab_shndx_list (abfd)->ndx])
asection *sec = shdrp->bfd_section;
bfd_boolean is_rel = (shdrp->sh_type == SHT_REL
|| shdrp->sh_type == SHT_RELA);
+ bfd_boolean is_ctf = sec && bfd_section_is_ctf (sec);
if (is_rel
+ || is_ctf
|| (sec != NULL && (sec->flags & SEC_ELF_COMPRESS)))
{
- if (!is_rel)
+ if (!is_rel && !is_ctf)
{
const char *name = sec->name;
struct bfd_elf_section_data *d;
shdrp->contents = sec->contents;
shdrp->bfd_section->contents = NULL;
}
+ else if (is_ctf)
+ {
+ /* Update section size and contents. */
+ shdrp->sh_size = sec->size;
+ shdrp->contents = sec->contents;
+ }
+
off = _bfd_elf_assign_file_position_for_section (shdrp,
off,
TRUE);
|| (segment->p_paddr \
? segment->p_paddr != section->lma \
: segment->p_vaddr != section->vma) \
- || (strcmp (bfd_get_section_name (ibfd, section), ".dynamic") \
- == 0)) \
+ || (strcmp (bfd_section_name (section), ".dynamic") == 0)) \
&& (segment->p_type != PT_LOAD || !section->segment_mark))
/* If the output section of a section in the input segment is NULL,
long symcount = bed->s->slurp_symbol_table (abfd, allocation, FALSE);
if (symcount >= 0)
- bfd_get_symcount (abfd) = symcount;
+ abfd->symcount = symcount;
return symcount;
}
long symcount = bed->s->slurp_symbol_table (abfd, allocation, TRUE);
if (symcount >= 0)
- bfd_get_dynamic_symcount (abfd) = symcount;
+ abfd->dynsymcount = symcount;
return symcount;
}
hdr = &elf_section_data (section)->this_hdr;
if (hdr->sh_offset == (file_ptr) -1)
{
+ if (bfd_section_is_ctf (section))
+ /* Nothing to do with this section: the contents are generated
+ later. */
+ return TRUE;
+
/* We must compress this section. Write output to the buffer. */
unsigned char *contents = hdr->contents;
if ((offset + count) > hdr->sh_size