[PATCH][PR22771] binutils/nm: nm does not display file/line information for inlined functions
The nm utility supports -l for using debug information to obtain file
and line information for each symbol, if available.
We have a tool that consumes this information and displays it.
This identified a problem with the 'nm' utility.
When a source is compiled with -O2, functions can be inlined. The
compiler also produces an uninlined copy of the function, normally for
linking to other object files.
In the case of DWARF2 debug information, the compiler generates debug
information to describe a function. If that function is inlined, the
compiler then references that debug information from the inlined and
uninlined copies of the routine through the use of the
When nm is used on such a file, it is not able to find file and line
information because that information is present in the common debug
information and not at each actual implementation of the function.
The 'nm' utility only retrieves the name of the function from the
abstract origin debug information and no more.
What I am proposing is to modify the find_abstract_instance_name()
function (which I renamed to find_abstract_instance() ) to return the
name of the function as well as any file and line information. The
routine is already parsing all of the debug information in the abstract
instance, so it is easy to pick up the file and line information at that
time. If, for some reason, the file and line information is not present,
the routine behaves as before.