Patchworkβ Out of order unwind entry warning

login
register
about
Submitter John David Anglin
Date 2009-10-29 19:16:43
Message ID <20091029191642.GA21129@hiauly1.hia.nrc.ca>
Download mbox | patch
Permalink /patch/56504/
State Not Applicable
Headers show

Comments

John David Anglin - 2009-10-29 19:16:43
On Wed, 28 Oct 2009, Helge Deller wrote:

> On 10/28/2009 11:43 PM, Helge Deller wrote:
>> On 10/28/2009 11:18 PM, John David Anglin wrote:
>>>>> and whether it follows inb in its .o. From my understanding of things,
>>>>> it shouldn't be necessary to remove the unwind info for unused weak
>>>>> symbols if they aren't garbage collected. A simple testcase would
>>>>> be helpful.
>
> Attached is a testcase (t1.c and t2.c):
> t1.c contains weak function f().
> t2.c contains non-weak function f().
>
> hppa-linux-gcc -c t1.c t2.c
> hppa-linux-ld -r -o all.o t1.o t2.o

Attached is a patch for gas that seems to produce reasonable
unwind info for the testcase when all.o is linked into a final
executable.  I think it will fix the linux unwind problem.

Still need to look at readelf -u on .o's.

Dave
Helge Deller - 2009-10-29 20:46:26
On 10/29/2009 08:16 PM, John David Anglin wrote:
> On Wed, 28 Oct 2009, Helge Deller wrote:
>
>> On 10/28/2009 11:43 PM, Helge Deller wrote:
>>> On 10/28/2009 11:18 PM, John David Anglin wrote:
>>>>>> and whether it follows inb in its .o. From my understanding of things,
>>>>>> it shouldn't be necessary to remove the unwind info for unused weak
>>>>>> symbols if they aren't garbage collected. A simple testcase would
>>>>>> be helpful.
>>
>> Attached is a testcase (t1.c and t2.c):
>> t1.c contains weak function f().
>> t2.c contains non-weak function f().
>>
>> hppa-linux-gcc -c t1.c t2.c
>> hppa-linux-ld -r -o all.o t1.o t2.o
>
> Attached is a patch for gas that seems to produce reasonable
> unwind info for the testcase when all.o is linked into a final
> executable.  I think it will fix the linux unwind problem.

Hi Dave,

Yes, this patch fixes the problem for vmlinux :-)
Just tested it with a 32bit  kernel build.

> Still need to look at readelf -u on .o's.

Yes, I see this too. readelf -u doesn't print any longer the second line of:
<arch_mod_section_prepend>: [0x1011fc4c-0x1011fc74]
           Entry_GR=1 Save_SP Total_frame_size=8

Thanks!

Helge
--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

Index: config/tc-hppa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.c,v
retrieving revision 1.145
diff -u -3 -p -r1.145 tc-hppa.c
--- config/tc-hppa.c	24 Jul 2009 11:45:00 -0000	1.145
+++ config/tc-hppa.c	29 Oct 2009 18:37:39 -0000
@@ -5961,13 +5961,41 @@  pa_build_unwind_subspace (struct call_in
   subsegT save_subseg;
   unsigned int unwind;
   int reloc;
-  char *p;
+  char *name, *p;
+  symbolS *symbolP;
 
   if ((bfd_get_section_flags (stdoutput, now_seg)
        & (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
       != (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
     return;
 
+  /* Replace the start symbol with a local symbol that will be reduced
+     to a section offset.  This avoids problems with weak functions with
+     multiple definitions, etc.  */
+  name = xmalloc (strlen ("L$\001start_")
+		  + strlen (S_GET_NAME (call_info->start_symbol))
+		  + 1);
+  strcpy (name, "L$\001start_");
+  strcat (name, S_GET_NAME (call_info->start_symbol));
+
+  /* If we have a .procend preceded by a .exit, then the symbol will have
+     already been defined.  In that case, we don't want another unwind
+     entry.  */
+  symbolP = symbol_find (name);
+  if (symbolP)
+    {
+      xfree (name);
+      return;
+    }
+  else
+    {
+      symbolP = symbol_new (name, now_seg,
+			    S_GET_VALUE (call_info->start_symbol), frag_now);
+      gas_assert (symbolP);
+      S_CLEAR_EXTERNAL (symbolP);
+      symbol_table_insert (symbolP);
+    }
+
   reloc = R_PARISC_SEGREL32;
   save_seg = now_seg;
   save_subseg = now_subseg;
@@ -5993,7 +6021,7 @@  pa_build_unwind_subspace (struct call_in
   /* Relocation info. for start offset of the function.  */
   md_number_to_chars (p, 0, 4);
   fix_new_hppa (frag_now, p - frag_now->fr_literal, 4,
-		call_info->start_symbol, (offsetT) 0,
+		symbolP, (offsetT) 0,
 		(expressionS *) NULL, 0, reloc,
 		e_fsel, 32, 0, 0);