This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: ld/2338: objdump -d -l doesn't work correctly


On Wed, Feb 15, 2006 at 12:52:47PM -0000, Dave Korn wrote:
> 
> 
> /*  Return FALSE if FUNC matches a function symbol from section SECTION
>   and is found in symbol table SYMBOL.  */
> 

I updated the comment. Please take a look.

> 
> ... perhaps you should move the abfd->flags test for a relocatable file
> outside the function, because it's a separate test really, and it's the only
> reason for passing in the abfd parameter so you could otherwise omit it?  It
> seems strange to see a function called "check_function_name" and the first
> thing it's doing is talking about whether two symbols can have the same
> address and how it relates to whether the object is relocatable or not; I'd
> put the comment and the test as part of the if-conditional at the call sites.
> 

check_function_name checks if there is a mismatch. We know it can only
happen in .o file. I think it is appropriate to check it there.


H.J.
----
2006-02-13  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/2338
	* dwarf2.c (check_function_name): New function.
	(_bfd_dwarf2_find_nearest_line): Use check_function_name to
	check if function is correct.

--- bfd/dwarf2.c.func	2006-01-20 08:53:55.000000000 -0800
+++ bfd/dwarf2.c	2006-02-15 13:47:20.000000000 -0800
@@ -2179,6 +2179,34 @@ find_debug_info (bfd *abfd, asection *af
   return NULL;
 }
 
+/* Return TRUE if there is no mismatch bewteen function FUNC and
+   section SECTION from symbol table SYMBOLS in ABFD.  */
+
+static bfd_boolean
+check_function_name (bfd *abfd, asection *section, asymbol **symbols,
+		     const char *func)
+{
+  /* Mismatch can only happen when we have 2 functions with the same
+     address. It can only occur in a relocatable file.  */
+  if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0
+      && func != NULL
+      && section != NULL
+      && symbols != NULL)
+    {
+      asymbol **p;
+
+      for (p = symbols; *p != NULL; p++)
+	{
+	  if (((*p)->flags & BSF_FUNCTION) != 0
+	      && (*p)->name != NULL
+	      && strcmp ((*p)->name, func) == 0)
+	    return (*p)->section == section;
+	}
+    }
+
+  return TRUE;
+}
+
 /* The DWARF2 version of find_nearest_line.  Return TRUE if the line
    is found without error.  ADDR_SIZE is the number of bytes in the
    initial .debug_info length field and in the abbreviation offset.
@@ -2300,7 +2328,9 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
     if (comp_unit_contains_address (each, addr)
 	&& comp_unit_find_nearest_line (each, addr, filename_ptr,
 					functionname_ptr,
-					linenumber_ptr, stash))
+					linenumber_ptr, stash)
+	&& check_function_name (abfd, section, symbols,
+				*functionname_ptr))
       return TRUE;
 
   /* Read each remaining comp. units checking each as they are read.  */
@@ -2368,7 +2398,9 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd
 						  filename_ptr,
 						  functionname_ptr,
 						  linenumber_ptr,
-						  stash))
+						  stash)
+		  && check_function_name (abfd, section, symbols,
+					  *functionname_ptr))
 		return TRUE;
 	    }
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]