From fa152c49304b325b423b55f8be8f00855fe9ed26 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Thu, 5 Oct 2000 22:22:27 +0000 Subject: [PATCH] Preserve machine dependent section header flags when reading ELF object file. * elf-bfd.h (struct elf_backend_data): Add elf_backend_section_flags field. * elf.c (_bfd_elf_make_section_from_shdr): Call the elf_backend_section_flags function. * elf64-ia64.c (elf64_ia64_section_from_shdr): Delete flag conversion code. (elf64_ia64_section_flags): New function containing flag conversion code. (elf_backend_section_flags): Define to elf64_ia64_section_flags. * elfxx-target.h (elf_backend_section_flags): Define. (elfNN_bed): Initialize elf_backend_section_flags field. --- bfd/ChangeLog | 14 ++++++++++++++ bfd/elf-bfd.h | 5 +++++ bfd/elf.c | 6 ++++++ bfd/elf64-ia64.c | 17 ++++++++++++++++- bfd/elfxx-target.h | 4 ++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 322ae48..dc4e67d 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,17 @@ +2000-10-05 Jim Wilson + + * elf-bfd.h (struct elf_backend_data): Add elf_backend_section_flags + field. + * elf.c (_bfd_elf_make_section_from_shdr): Call the + elf_backend_section_flags function. + * elf64-ia64.c (elf64_ia64_section_from_shdr): Delete flag conversion + code. + (elf64_ia64_section_flags): New function containing flag conversion + code. + (elf_backend_section_flags): Define to elf64_ia64_section_flags. + * elfxx-target.h (elf_backend_section_flags): Define. + (elfNN_bed): Initialize elf_backend_section_flags field. + 2000-10-02 Alan Modra * elf32-hppa.c (elf32_hppa_check_relocs): Correct call to diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index b84948f..574411c 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -391,6 +391,11 @@ struct elf_backend_data Elf32_Internal_Shdr *, char *)); + /* A function to convert machine dependent section header flags to + BFD internal section header flags. */ + boolean (*elf_backend_section_flags) PARAMS ((flagword *, + Elf32_Internal_Shdr *)); + /* A function to handle unusual program segment types when creating BFD sections from ELF program segments. */ boolean (*elf_backend_section_from_phdr) PARAMS ((bfd *, diff --git a/bfd/elf.c b/bfd/elf.c index 5dac0a3..3aede14 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -345,6 +345,7 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) { asection *newsect; flagword flags; + struct elf_backend_data *bed; if (hdr->bfd_section != NULL) { @@ -410,6 +411,11 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0) flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; + bed = get_elf_backend_data (abfd); + if (bed->elf_backend_section_flags) + if (! bed->elf_backend_section_flags (&flags, hdr)) + return false; + if (! bfd_set_section_flags (abfd, newsect, flags)) return false; diff --git a/bfd/elf64-ia64.c b/bfd/elf64-ia64.c index f1ea331..cc63838 100644 --- a/bfd/elf64-ia64.c +++ b/bfd/elf64-ia64.c @@ -946,8 +946,21 @@ elf64_ia64_section_from_shdr (abfd, hdr, name) return false; newsect = hdr->bfd_section; + return true; +} + +/* Convert IA-64 specific section flags to bfd internal section flags. */ + +/* ??? There is no bfd internal flag equivalent to the SHF_IA_64_NORECOV + flag. */ + +static boolean +elf64_ia64_section_flags (flags, hdr) + flagword *flags; + Elf64_Internal_Shdr *hdr; +{ if (hdr->sh_flags & SHF_IA_64_SHORT) - newsect->flags |= SEC_SMALL_DATA; + *flags |= SEC_SMALL_DATA; return true; } @@ -4064,6 +4077,8 @@ elf64_ia64_print_private_bfd_data (abfd, ptr) #define elf_backend_section_from_shdr \ elf64_ia64_section_from_shdr +#define elf_backend_section_flags \ + elf64_ia64_section_flags #define elf_backend_fake_sections \ elf64_ia64_fake_sections #define elf_backend_add_symbol_hook \ diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 4c3ca1c..6957e3a 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -237,6 +237,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef elf_backend_section_from_shdr #define elf_backend_section_from_shdr 0 #endif +#ifndef elf_backend_section_flags +#define elf_backend_section_flags 0 +#endif #ifndef elf_backend_section_from_phdr #define elf_backend_section_from_phdr 0 #endif @@ -368,6 +371,7 @@ static CONST struct elf_backend_data elfNN_bed = elf_backend_get_symbol_type, elf_backend_section_processing, elf_backend_section_from_shdr, + elf_backend_section_flags, elf_backend_section_from_phdr, elf_backend_fake_sections, elf_backend_section_from_bfd_section, -- 2.7.4