This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: ld/2338: objdump -d -l doesn't work correctly
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Andrew Morton <akpm at osdl dot org>, binutils at sources dot redhat dot com
- Date: Tue, 14 Feb 2006 15:24:00 -0800
- Subject: Re: PATCH: ld/2338: objdump -d -l doesn't work correctly
- References: <20060214192803.GA12332@lucon.org> <jeacctimb6.fsf@sykes.suse.de>
On Tue, Feb 14, 2006 at 11:54:05PM +0100, Andreas Schwab wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
>
> > +/* Return FALSE if FUNC in symbol table SYMBOLS is not relative to
> > + SECTION. */
>
> Double negation is not easy to not misunderstand.
>
I am trying to say that only FALSE return is reliable since TRUE can
return under other conditions. Maybe I should change the function
name to function_name_section_mismatch.
Here is an updated patch to restrict to relocatable files.
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-14 13:29:09.000000000 -0800
@@ -2179,6 +2179,34 @@ find_debug_info (bfd *abfd, asection *af
return NULL;
}
+/* Return FALSE if FUNC in symbol table SYMBOLS is not relative to
+ SECTION in ABFD. */
+
+static bfd_boolean
+check_function_name (bfd *abfd, asection *section, asymbol **symbols,
+ const char *func)
+{
+ /* Only a relocatable file can have 2 symbols with the same
+ address. */
+ 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;
}
}