* 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.
This commit is contained in:
Mark Mitchell 1999-06-02 13:01:04 +00:00
parent 3fe702fddf
commit bf572ba0b9
6 changed files with 96 additions and 22 deletions

View file

@ -1,3 +1,22 @@
1999-05-31 Mark Mitchell <mark@codesourcery.com>
* 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.
Wed Jun 2 12:38:49 1999 Miodrag Vallat <miodrag@multimania.com>
* hosts/alphalinux.h (TRAD_CORE_EXTRA_SIZE_ALLOWED): Expand to 4096.

View file

@ -255,11 +255,6 @@ struct elf_size_info {
struct elf_backend_data
{
/* Whether the backend uses REL or RELA relocations. FIXME: some
ELF backends use both. When we need to support one, this whole
approach will need to be changed. */
int use_rela_p;
/* The architecture for this backend. */
enum bfd_architecture arch;
@ -540,6 +535,23 @@ struct elf_backend_data
bfd_vma got_header_size;
bfd_vma plt_header_size;
/* Whether the backend may use REL relocations. (Some backends use
both REL and RELA relocations, and this flag is set for those
backends.) */
unsigned may_use_rel_p : 1;
/* Whether the backend may use RELA relocations. (Some backends use
both REL and RELA relocations, and this flag is set for those
backends.) */
unsigned may_use_rela_p : 1;
/* Whether the default relocation type is RELA. If a backend with
this flag set wants REL relocations for a particular section,
it must note that explicitly. Similarly, if this flag is clear,
and the backend wants RELA relocations for a particular
section. */
unsigned default_use_rela_p : 1;
unsigned want_got_plt : 1;
unsigned plt_readonly : 1;
unsigned want_plt_sym : 1;
@ -582,6 +594,8 @@ struct bfd_elf_section_data
PTR stab_info;
/* A pointer available for the processor specific ELF backend. */
PTR tdata;
/* Nonzero if this section uses RELA relocations, rather than REL. */
unsigned int use_rela_p:1;
};
#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)

View file

@ -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 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;
}

View file

@ -729,7 +729,7 @@ write_relocs (abfd, sec, data)
Elf_External_Rela *outbound_relocas;
Elf_External_Rel *outbound_relocs;
unsigned int idx;
int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
int use_rela_p;
asymbol *last_sym = 0;
int last_sym_idx = 0;
@ -757,6 +757,16 @@ write_relocs (abfd, sec, data)
return;
}
/* Figure out whether the relocations are RELA or REL relocations. */
if (rela_hdr->sh_type == SHT_RELA)
use_rela_p = true;
else if (rela_hdr->sh_type == SHT_REL)
use_rela_p = false;
else
/* Every relocation section should be either an SHT_RELA or an
SHT_REL section. */
abort ();
/* orelocation has the data, reloc_count has the count... */
if (use_rela_p)
{

View file

@ -147,7 +147,8 @@ _bfd_elf_create_dynamic_sections (abfd, info)
return false;
}
s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.plt" : ".rel.plt");
s = bfd_make_section (abfd,
bed->default_use_rela_p ? ".rela.plt" : ".rel.plt");
if (s == NULL
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|| ! bfd_set_section_alignment (abfd, s, ptralign))
@ -180,7 +181,9 @@ _bfd_elf_create_dynamic_sections (abfd, info)
copy relocs. */
if (! info->shared)
{
s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.bss" : ".rel.bss");
s = bfd_make_section (abfd,
(bed->default_use_rela_p
? ".rela.bss" : ".rel.bss"));
if (s == NULL
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|| ! bfd_set_section_alignment (abfd, s, ptralign))

View file

@ -294,6 +294,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define elf_backend_post_process_headers NULL
#endif
/* Previously, backends could only use SHT_REL or SHT_RELA relocation
sections, but not both. They defined USE_REL to indicate SHT_REL
sections, and left it undefined to indicated SHT_RELA sections.
For backwards compatibility, we still support this usage. */
#ifndef USE_REL
#define USE_REL 0
#else
#undef USE_REL
#define USE_REL 1
#endif
/* Use these in new code. */
#ifndef elf_backend_may_use_rel_p
#define elf_backend_may_use_rel_p USE_REL
#endif
#ifndef elf_backend_may_use_rela_p
#define elf_backend_may_use_rela_p !USE_REL
#endif
#ifndef elf_backend_default_use_rela_p
#define elf_backend_default_use_rela_p !USE_REL
#endif
#ifndef ELF_MACHINE_ALT1
#define ELF_MACHINE_ALT1 0
#endif
@ -310,11 +332,6 @@ extern const struct elf_size_info _bfd_elfNN_size_info;
static CONST struct elf_backend_data elfNN_bed =
{
#ifdef USE_REL
0, /* use_rela_p */
#else
1, /* use_rela_p */
#endif
ELF_ARCH, /* arch */
ELF_MACHINE_CODE, /* elf_machine_code */
ELF_MAXPAGESIZE, /* maxpagesize */
@ -355,6 +372,9 @@ static CONST struct elf_backend_data elfNN_bed =
elf_backend_got_symbol_offset,
elf_backend_got_header_size,
elf_backend_plt_header_size,
elf_backend_may_use_rel_p,
elf_backend_may_use_rela_p,
elf_backend_default_use_rela_p,
elf_backend_want_got_plt,
elf_backend_plt_readonly,
elf_backend_want_plt_sym,