+1999-11-26 Fred Fish <fnf@cygnus.com>
+
+ * elf.c (elfcore_read_notes): Add prototype for static function.
+ (_bfd_elf_make_section_from_phdr): Renamed from bfd_section_from_phdr.
+ (bfd_section_from_phdr): Replacement function that calls
+ _bfd_elf_make_section_from_phdr for generic segment types and
+ backend fucntion pointed to by elf_backend_section_from_phdr for
+ backend specific segment types.
+ (_bfd_elfcore_section_from_phdr): Remove call to elfcore_read_notes,
+ now called by _bfd_elf_make_section_from_phdr. Note that this func
+ is now just a stub between the caller and bfd_section_from_phdr.
+
+ * elf-bfd.h (struct elf_backend_data): Add new function pointer
+ elf_backend_section_from_phdr.
+ (elf_backend_section_from_phdr): Add prototype.
+
+ * elfxx-target.h (elf_backend_section_from_phdr): Define default.
+ (elfNN_bed): Add elf_backend_section_from_phdr.
+
1999-11-25 Nick Clifton <nickc@cygnus.com>
* coff-arm.c (bfd_arm_get_bfd_for_interworking): Add
Elf32_Internal_Shdr *,
char *));
+ /* A function to handle unusual program segment types when creating BFD
+ sections from ELF program segments. */
+ boolean (*elf_backend_section_from_phdr) PARAMS ((bfd *,
+ Elf32_Internal_Phdr *,
+ int));
+
/* A function to set up the ELF section header for a BFD section in
preparation for writing it out. This is where the flags and type
fields are set for unusual sections. */
extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
extern boolean _bfd_elf_make_section_from_shdr
PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
+extern boolean _bfd_elf_make_section_from_phdr
+ PARAMS ((bfd *abfd, Elf_Internal_Phdr *hdr, int index, const char *typename));
extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
static INLINE int sym_is_global PARAMS ((bfd *, asymbol *));
static boolean elf_map_symbols PARAMS ((bfd *));
static bfd_size_type get_program_header_size PARAMS ((bfd *));
+static boolean elfcore_read_notes PARAMS ((bfd *, bfd_vma, bfd_vma));
/* Swap version information in and out. The version information is
currently size independent. If that ever changes, this code will
*/
boolean
-bfd_section_from_phdr (abfd, hdr, index)
+_bfd_elf_make_section_from_phdr (abfd, hdr, index, typename)
bfd *abfd;
Elf_Internal_Phdr *hdr;
int index;
+ const char *typename;
{
asection *newsect;
char *name;
- char *typename;
char namebuf[64];
int split;
split = ((hdr->p_memsz > 0)
&& (hdr->p_filesz > 0)
&& (hdr->p_memsz > hdr->p_filesz));
- switch (hdr->p_type)
- {
- case PT_NULL: typename = "null"; break;
- case PT_LOAD: typename = "load"; break;
- case PT_DYNAMIC: typename = "dynamic"; break;
- case PT_INTERP: typename = "interp"; break;
- case PT_NOTE: typename = "note"; break;
- case PT_SHLIB: typename = "shlib"; break;
- case PT_PHDR: typename = "phdr"; break;
- default: typename = "segment"; break;
- }
sprintf (namebuf, "%s%d%s", typename, index, split ? "a" : "");
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
return true;
}
+boolean
+bfd_section_from_phdr (abfd, hdr, index)
+ bfd *abfd;
+ Elf_Internal_Phdr *hdr;
+ int index;
+{
+ struct elf_backend_data *bed;
+
+ switch (hdr->p_type)
+ {
+ case PT_NULL:
+ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "null");
+
+ case PT_LOAD:
+ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "load");
+
+ case PT_DYNAMIC:
+ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "dynamic");
+
+ case PT_INTERP:
+ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "interp");
+
+ case PT_NOTE:
+ if (! _bfd_elf_make_section_from_phdr (abfd, hdr, index, "note"))
+ return false;
+ if (! elfcore_read_notes (abfd, hdr->p_offset, hdr->p_filesz))
+ return false;
+ return true;
+
+ case PT_SHLIB:
+ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "shlib");
+
+ case PT_PHDR:
+ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "phdr");
+
+ default:
+ /* Check for any processor-specific program segment types.
+ If no handler for them, default to making "segment" sections. */
+ bed = get_elf_backend_data (abfd);
+ if (bed->elf_backend_section_from_phdr)
+ return (*bed->elf_backend_section_from_phdr) (abfd, hdr, index);
+ else
+ return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "segment");
+ }
+}
+
/* Initialize REL_HDR, the section-header for new section, containing
relocations against ASECT. If USE_RELA_P is true, we use RELA
relocations; otherwise, we use REL relocations. */
}
+/* FIXME: This function is now unnecessary. Callers can just call
+ bfd_section_from_phdr directly. */
boolean
_bfd_elfcore_section_from_phdr (abfd, phdr, sec_num)
if (! bfd_section_from_phdr (abfd, phdr, sec_num))
return false;
- if (phdr->p_type == PT_NOTE
- && ! elfcore_read_notes (abfd, phdr->p_offset, phdr->p_filesz))
- return false;
-
return true;
}
#ifndef elf_backend_section_from_shdr
#define elf_backend_section_from_shdr 0
#endif
+#ifndef elf_backend_section_from_phdr
+#define elf_backend_section_from_phdr 0
+#endif
#ifndef elf_backend_fake_sections
#define elf_backend_fake_sections 0
#endif
elf_backend_get_symbol_type,
elf_backend_section_processing,
elf_backend_section_from_shdr,
+ elf_backend_section_from_phdr,
elf_backend_fake_sections,
elf_backend_section_from_bfd_section,
elf_backend_add_symbol_hook,