- else if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
- && hdr->bfd_section == NULL)
- || (hdr->bfd_section != NULL
- && (hdr->bfd_section->flags & SEC_ELF_COMPRESS))
- /* Compress DWARF debug sections. */
- || hdr == i_shdrpp[elf_onesymtab (abfd)]
- || (elf_symtab_shndx_list (abfd) != NULL
- && hdr == i_shdrpp[elf_symtab_shndx_list (abfd)->ndx])
- || hdr == i_shdrpp[elf_strtab_sec (abfd)]
- || hdr == i_shdrpp[elf_shstrtab_sec (abfd)])
- hdr->sh_offset = -1;
- else
- off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
- }
-
- /* Now that we have set the section file positions, we can set up
- the file positions for the non PT_LOAD segments. */
- count = 0;
- filehdr_vaddr = 0;
- filehdr_paddr = 0;
- phdrs_vaddr = bed->maxpagesize + bed->s->sizeof_ehdr;
- phdrs_paddr = 0;
- hdrs_segment = NULL;
- phdrs = elf_tdata (abfd)->phdr;
- for (m = elf_seg_map (abfd), p = phdrs; m != NULL; m = m->next, p++)
- {
- ++count;
- if (p->p_type != PT_LOAD)
- continue;
-
- if (m->includes_filehdr)
- {
- filehdr_vaddr = p->p_vaddr;
- filehdr_paddr = p->p_paddr;
- }
- if (m->includes_phdrs)
- {
- phdrs_vaddr = p->p_vaddr;
- phdrs_paddr = p->p_paddr;
- if (m->includes_filehdr)
- {
- hdrs_segment = m;
- phdrs_vaddr += bed->s->sizeof_ehdr;
- phdrs_paddr += bed->s->sizeof_ehdr;
- }
- }
- }
-
- if (hdrs_segment != NULL && link_info != NULL)
- {
- /* There is a segment that contains both the file headers and the
- program headers, so provide a symbol __ehdr_start pointing there.
- A program can use this to examine itself robustly. */
-
- struct elf_link_hash_entry *hash
- = elf_link_hash_lookup (elf_hash_table (link_info), "__ehdr_start",
- FALSE, FALSE, TRUE);
- /* If the symbol was referenced and not defined, define it. */
- if (hash != NULL
- && (hash->root.type == bfd_link_hash_new
- || hash->root.type == bfd_link_hash_undefined
- || hash->root.type == bfd_link_hash_undefweak
- || hash->root.type == bfd_link_hash_common))
- {
- asection *s = NULL;
- if (hdrs_segment->count != 0)
- /* The segment contains sections, so use the first one. */
- s = hdrs_segment->sections[0];
- else
- /* Use the first (i.e. lowest-addressed) section in any segment. */
- for (m = elf_seg_map (abfd); m != NULL; m = m->next)
- if (m->count != 0)
- {
- s = m->sections[0];
- break;
- }
-
- if (s != NULL)
- {
- hash->root.u.def.value = filehdr_vaddr - s->vma;
- hash->root.u.def.section = s;
- }
- else
- {
- hash->root.u.def.value = filehdr_vaddr;
- hash->root.u.def.section = bfd_abs_section_ptr;
- }
-
- hash->root.type = bfd_link_hash_defined;
- hash->def_regular = 1;
- hash->non_elf = 0;
- }
+ 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
+ || (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])
+ || hdr == i_shdrpp[elf_strtab_sec (abfd)]
+ || hdr == i_shdrpp[elf_shstrtab_sec (abfd)])
+ hdr->sh_offset = -1;
+ else
+ off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);