bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sparc-lp64: stab section entsize wrong


From: Marco Walther
Subject: Re: sparc-lp64: stab section entsize wrong
Date: Mon, 8 Jul 2002 12:34:37 -0700

>>>>> "AM" == Alan Modra <address@hidden> writes:

AM> On Thu, Jun 27, 2002 at 03:15:22PM -0700, Marco Walther wrote:
>> Hi,
>> 
>> the subject says it all.  Gas out of binutils-2.12.1 produces an
>> sh_entsize of 0x14 for the .stab section when building a 64bit object.
>> But the stab entries are still 12 (0x0c) bytes long even for 64bit
>> objects.

>> --- binutils-2.12.1/bfd/elf.c.orig   Thu May  9 07:48:54 2002
>> +++ binutils-2.12.1/bfd/elf.c        Thu Jun 27 15:07:44 2002
>> @@ -2547,8 +2547,17 @@
>> elf_section_data (s)->this_hdr.sh_link = d->this_idx;
>> 
>> /* This is a .stab section.  */
>> -              elf_section_data (s)->this_hdr.sh_entsize =
>> -                4 + 2 * bfd_get_arch_size (abfd) / 8;
>> +              if (bfd_mach_sparc_v9_p(bfd_get_arch(abfd)))

AM> This is very broken.  Also, it is better to keep arch specific code
AM> out of the generic code.

The original code is not a lot better there;-)  Yes it looks like a
convenient place to fixup this entry size.  But it's kind of hard to
find this place later one.


AM> An acceptable fix might be to modify the code you're patching above to
AM> only set sh_entsize if zero (I think it defaults to zero, not sure),

Yes, most of the sh_entsize fields are never set and so default to
zero.


AM> and set up the sparc sh_entsize value in a new
AM> elf_backend_fake_sections function living in elf64-sparc.c.

Maybe the following patch looks better to you;-)

Thanks,
-- Marco
---------------------------------------------------------------------------
--- binutils-2.12.1/bfd/elf.c.orig      Thu May  9 07:48:54 2002
+++ binutils-2.12.1/bfd/elf.c   Mon Jul  8 11:17:26 2002
@@ -2547,8 +2547,13 @@
                  elf_section_data (s)->this_hdr.sh_link = d->this_idx;
 
                  /* This is a .stab section.  */
-                 elf_section_data (s)->this_hdr.sh_entsize =
-                   4 + 2 * bfd_get_arch_size (abfd) / 8;
+                               /* MARCO: That's quite a hidden place
+                                  to do this late fixup.  */
+                 if (elf_section_data (s)->this_hdr.sh_entsize == 0)
+                   {
+                     elf_section_data (s)->this_hdr.sh_entsize =
+                       4 + 2 * bfd_get_arch_size (abfd) / 8;
+                   }
                }
            }
          break;
--- binutils-2.12.1/bfd/elf64-sparc.c.orig      Thu May  9 07:49:01 2002
+++ binutils-2.12.1/bfd/elf64-sparc.c   Mon Jul  8 11:30:26 2002
@@ -72,6 +72,9 @@
 static boolean sparc64_elf_merge_private_bfd_data
   PARAMS ((bfd *, bfd *));
 
+static boolean sparc64_elf_fake_sections
+  PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
+
 static const char *sparc64_elf_print_symbol_all
   PARAMS ((bfd *, PTR, asymbol *));
 static boolean sparc64_elf_relax_section
@@ -2995,6 +2998,32 @@
     }
   return true;
 }
+
+
+/* MARCO: Set the correct entry size for the .stab section in the
+   64bit case.  The sh_entsize is otherwise set in
+   elf.c:assign_section_numbers() */
+
+static boolean
+sparc64_elf_fake_sections (abfd, hdr, sec)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED;
+     asection *sec;
+{
+  register const char *name;
+
+  name = bfd_get_section_name (abfd, sec);
+
+  if (strcmp (name, ".stab") == 0)
+    {
+                               /* Even in the 64bit case the stab
+                                  entries are only 12 bytes long.  */
+      elf_section_data(sec)->this_hdr.sh_entsize = 12;
+    }
+  
+  return true;
+}
+
 
 /* Print a STT_REGISTER symbol to file FILE.  */
 
@@ -3131,6 +3160,8 @@
   sparc64_elf_output_arch_syms
 #define bfd_elf64_bfd_merge_private_bfd_data \
   sparc64_elf_merge_private_bfd_data
+#define elf_backend_fake_sections \
+  sparc64_elf_fake_sections
 
 #define elf_backend_size_info \
   sparc64_elf_size_info

-- 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]