aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-06-02 13:01:04 +0000
committerMark Mitchell <mark@codesourcery.com>1999-06-02 13:01:04 +0000
commitbf572ba0b9deeeba341d197a3412a3c0b44d819f (patch)
treeca0102a08126c8ccfea30b798468cc30711e95a7 /bfd/elf.c
parent3fe702fddf7a4fc4eef46bcee1bcfada94e72627 (diff)
downloadgdb-bf572ba0b9deeeba341d197a3412a3c0b44d819f.zip
gdb-bf572ba0b9deeeba341d197a3412a3c0b44d819f.tar.gz
gdb-bf572ba0b9deeeba341d197a3412a3c0b44d819f.tar.bz2
* elf-bfd.h (elf_backend_data): Remove use_rela_p. Add
may_use_rel_p, may_use_rela_p, default_use_rela_p. (bfd_elf_section_data): Add use_rela_p. * elf.c (bfd_section_from_shdr): Set use_rela_p appropriately. (_bfd_elf_new_section_hook): Likewise. (elf_fake_sections): Use may_use_rela_p, etc., instead of use_rela_p. (_bfd_elf_copy_private_section_data): Copy use_rela_p. * elfcode.h (write_relocs): Determine whether or not use rela relocs based on the relocation section header. * elflink.c (_bfd_elf_create_dynamic_sections): Use default_use_rela_p instead of use_rela_p. * elfxx-target.h (elf_backend_may_use_relp): New macro. (elf_backend_may_use_rela_p): Likewise. (elf_backend_default_use_rela_p): Likewise. (elfNN_bed): Use them.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 135e553..1e162b0 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1265,6 +1265,10 @@ bfd_section_from_shdr (abfd, shindex)
target_sect->flags |= SEC_RELOC;
target_sect->relocation = NULL;
target_sect->rel_filepos = hdr->sh_offset;
+ /* In the section to which the relocations apply, mark whether
+ its relocations are of the REL or RELA variety. */
+ elf_section_data (target_sect)->use_rela_p
+ = (hdr->sh_type == SHT_RELA);
abfd->flags |= HAS_RELOC;
return true;
}
@@ -1329,6 +1333,11 @@ _bfd_elf_new_section_hook (abfd, sec)
return false;
sec->used_by_bfd = (PTR) sdata;
memset (sdata, 0, sizeof (*sdata));
+
+ /* Indicate whether or not this section should use RELA relocations. */
+ sdata->use_rela_p
+ = get_elf_backend_data (abfd)->default_use_rela_p;
+
return true;
}
@@ -1491,13 +1500,13 @@ elf_fake_sections (abfd, asect, failedptrarg)
this_hdr->sh_entsize = bed->s->sizeof_dyn;
}
else if (strncmp (asect->name, ".rela.", 6) == 0
- && get_elf_backend_data (abfd)->use_rela_p)
+ && get_elf_backend_data (abfd)->may_use_rela_p)
{
this_hdr->sh_type = SHT_RELA;
this_hdr->sh_entsize = bed->s->sizeof_rela;
}
else if (strncmp (asect->name, ".rel.", 5) == 0
- && ! get_elf_backend_data (abfd)->use_rela_p)
+ && get_elf_backend_data (abfd)->may_use_rel_p)
{
this_hdr->sh_type = SHT_REL;
this_hdr->sh_entsize = bed->s->sizeof_rel;
@@ -1558,19 +1567,15 @@ elf_fake_sections (abfd, asect, failedptrarg)
this_hdr->sh_flags |= SHF_EXECINSTR;
/* Check for processor-specific section types. */
- {
- struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
- if (bed->elf_backend_fake_sections)
- (*bed->elf_backend_fake_sections) (abfd, this_hdr, asect);
- }
+ if (bed->elf_backend_fake_sections)
+ (*bed->elf_backend_fake_sections) (abfd, this_hdr, asect);
/* If the section has relocs, set up a section header for the
SHT_REL[A] section. */
if ((asect->flags & SEC_RELOC) != 0)
{
Elf_Internal_Shdr *rela_hdr;
- int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
+ int use_rela_p = elf_section_data (asect)->use_rela_p;
char *name;
rela_hdr = &elf_section_data (asect)->rel_hdr;
@@ -3837,6 +3842,9 @@ _bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec)
|| ihdr->sh_type == SHT_GNU_verdef)
ohdr->sh_info = ihdr->sh_info;
+ elf_section_data (osec)->use_rela_p
+ = elf_section_data (isec)->use_rela_p;
+
return true;
}