any side effects in ABFD, or any data it points to (like tdata), if the
file does not match the target vector. */
-const bfd_target *
+bfd_cleanup
elf_object_p (bfd *abfd)
{
Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
s->flags |= SEC_DEBUGGING;
}
}
- return target;
+ return _bfd_no_cleanup;
got_wrong_format_error:
bfd_set_error (bfd_error_wrong_format);
void
elf_write_relocs (bfd *abfd, asection *sec, void *data)
{
+ const struct elf_backend_data * const bed = get_elf_backend_data (abfd);
bfd_boolean *failedp = (bfd_boolean *) data;
Elf_Internal_Shdr *rela_hdr;
bfd_vma addr_offset;
src_rela.r_addend = ptr->addend;
(*swap_out) (abfd, &src_rela, dst_rela);
}
+
+ if (!bed->write_secondary_relocs (abfd, sec))
+ {
+ *failedp = TRUE;
+ return;
+ }
}
/* Write out the program headers. */
{
/* This symbol is in a section for which we did not
create a BFD section. Just use bfd_abs_section,
- although it is wrong. FIXME. */
+ although it is wrong. FIXME. Note - there is
+ code in elf.c:swap_out_syms that calls
+ symbol_section_index() in the elf backend for
+ cases like this. */
sym->symbol.section = bfd_abs_section_ptr;
}
}
asymbol **symbols,
bfd_boolean dynamic)
{
+ const struct elf_backend_data * const bed = get_elf_backend_data (abfd);
struct bfd_elf_section_data * const d = elf_section_data (asect);
Elf_Internal_Shdr *rel_hdr;
Elf_Internal_Shdr *rel_hdr2;
symbols, dynamic))
return FALSE;
+ if (!bed->slurp_secondary_relocs (abfd, asect, symbols))
+ return FALSE;
+
asect->relocation = relents;
return TRUE;
}
bfd *
NAME(_bfd_elf,bfd_from_remote_memory)
(bfd *templ,
- bfd_vma ehdr_vma,
- bfd_size_type size,
- bfd_vma *loadbasep,
+ bfd_vma ehdr_vma /* Bytes. */,
+ bfd_size_type size /* Octets. */,
+ bfd_vma *loadbasep /* Bytes. */,
int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type))
+ /* (Bytes , , octets ). */
{
Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */
unsigned int i;
bfd_vma high_offset;
bfd_vma shdr_end;
- bfd_vma loadbase;
+ bfd_vma loadbase; /* Bytes. */
char *filename;
size_t amt;
+ unsigned int opb = bfd_octets_per_byte (templ, NULL);
/* Read in the ELF header in external format. */
err = target_read_memory (ehdr_vma, (bfd_byte *) &x_ehdr, sizeof x_ehdr);
header sits, then we can figure out the loadbase. */
if (first_phdr == NULL)
{
- bfd_vma p_offset = i_phdrs[i].p_offset;
- bfd_vma p_vaddr = i_phdrs[i].p_vaddr;
+ bfd_vma p_offset = i_phdrs[i].p_offset; /* Octets. */
+ bfd_vma p_vaddr = i_phdrs[i].p_vaddr; /* Octets. */
if (i_phdrs[i].p_align > 1)
{
- p_offset &= -i_phdrs[i].p_align;
- p_vaddr &= -i_phdrs[i].p_align;
+ p_offset &= -(i_phdrs[i].p_align * opb);
+ p_vaddr &= -(i_phdrs[i].p_align * opb);
}
if (p_offset == 0)
{
- loadbase = ehdr_vma - p_vaddr;
+ loadbase = ehdr_vma - p_vaddr / opb;
first_phdr = &i_phdrs[i];
}
}
for (i = 0; i < i_ehdr.e_phnum; ++i)
if (i_phdrs[i].p_type == PT_LOAD)
{
- bfd_vma start = i_phdrs[i].p_offset;
- bfd_vma end = start + i_phdrs[i].p_filesz;
- bfd_vma vaddr = i_phdrs[i].p_vaddr;
+ bfd_vma start = i_phdrs[i].p_offset; /* Octets. */
+ bfd_vma end = start + i_phdrs[i].p_filesz; /* Octets. */
+ bfd_vma vaddr = i_phdrs[i].p_vaddr; /* Octets. */
/* Extend the beginning of the first pt_load to cover file
header and program headers, if we proved earlier that its
/* Extend the end of the last pt_load to cover section headers. */
if (last_phdr == &i_phdrs[i])
end = high_offset;
- err = target_read_memory (loadbase + vaddr,
+ err = target_read_memory (loadbase + vaddr / opb,
contents + start, end - start);
if (err)
{