Better default for elf_backend_section_from_shdr

Zack Weinberg zack@codesourcery.com
Wed Mar 2 04:12:00 GMT 2005


Alan Modra <amodra@bigpond.net.au> writes:

> Definitely for elf_backend_section_from_phdr.  See the default case in
> elf.c:bfd_section_from_phdr.  Please clean this up while you're at it,
> to call the backend function unconditionally.  Same in
> bfd_section_from_shdr.

I'm not sure I understand this request.  The appended patch does what
I think you meant.  Please verify?

zw

        * elf.c (bfd_section_from_shdr <default case>): 
        Call elf_backend_section_from_shdr hook unconditionally, and
        return what it returns.
        (bfd_section_from_phdr): Similarly, for elf_backend_section_from_phdr.
        * elfxx-target.h (elf_backend_section_from_shdr)
        (elf_backend_section_from_phdr): Default to
        _bfd_elf_make_section_from_shdr and _bfd_elf_make_section_from_phdr
        respectively.

===================================================================
Index: bfd/elf.c
--- bfd/elf.c	23 Feb 2005 09:46:48 -0000	1.267
+++ bfd/elf.c	2 Mar 2005 04:08:05 -0000
@@ -2039,9 +2039,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
 
     default:
       /* Check for any processor-specific section types.  */
-      if (bed->elf_backend_section_from_shdr)
-	(*bed->elf_backend_section_from_shdr) (abfd, hdr, name);
-      break;
+      return bed->elf_backend_section_from_shdr (abfd, hdr, name);
     }
 
   return TRUE;
@@ -2379,13 +2377,9 @@ bfd_section_from_phdr (bfd *abfd, Elf_In
       return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "relro");
 
     default:
-      /* Check for any processor-specific program segment types.
-         If no handler for them, default to making "segment" sections.  */
+      /* Check for any processor-specific program segment types.  */
       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");
+      return bed->elf_backend_section_from_phdr (abfd, hdr, index);
     }
 }
 
===================================================================
Index: bfd/elfxx-target.h
--- bfd/elfxx-target.h	22 Feb 2005 00:50:04 -0000	1.78
+++ bfd/elfxx-target.h	2 Mar 2005 04:08:05 -0000
@@ -326,13 +326,13 @@
 #define elf_backend_section_processing	0
 #endif
 #ifndef elf_backend_section_from_shdr
-#define elf_backend_section_from_shdr	0
+#define elf_backend_section_from_shdr	_bfd_elf_make_section_from_shdr
 #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
+#define elf_backend_section_from_phdr	_bfd_elf_make_section_from_phdr
 #endif
 #ifndef elf_backend_fake_sections
 #define elf_backend_fake_sections	0



More information about the Binutils mailing list