[Bug symtab/24802] New: Weak symbol aliases missing in the overload set

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Bug symtab/24802] New: Weak symbol aliases missing in the overload set

fweimer at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24802

            Bug ID: 24802
           Summary: Weak symbol aliases missing in the overload set
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: mihails.strasuns at intel dot com
  Target Milestone: ---

Consider the following C++ snippet:

---
template <typename T>
T foo (T t) { return t; }

template int foo<int>(int t);
template char foo<char>(char t);

__attribute__ ((weak, alias ("_Z3fooIcET_S0_")))
char bar (char x);
__attribute__ ((weak, alias ("_Z3fooIiET_S0_")))
int bar (int x);

void main () {}
---

When loading the executable (compiled by gcc), gdb will load both `bar` entries
into a minimal symbol table, as expected. However, when trying to evaluate the
`bar(42)` expression by gdb, a wrong (char) overload will be called.

This happens because C/C++ expression parser converts found minimal symbol into
a matching regular symbol by calling `find_function_alias_target` and only uses
the found match later. `find_function_alias_target` does not take arguments
into consideration and will return `_Z3fooIcET_S0_` as a first matching entry.

Conceptually it is a bug, as there is a mismatch between the expression
evaluation in gdb and the behavior of same expression compiled by gcc.

Is this something that should be expected to work?

--
You are receiving this mail because:
You are on the CC list for the bug.