diff options
author | Pedro Alves <palves@redhat.com> | 2018-04-26 13:01:26 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2018-04-26 13:04:09 +0100 |
commit | a376e11d84ba7ea8cc7333c77043e20c7b0cfc91 (patch) | |
tree | d28d8b4f0bc9dc7f75c76fc61dd75e110aab53be | |
parent | 02e169e2dac9b0354162eb0e7ee3fc95134b232d (diff) | |
download | gdb-a376e11d84ba7ea8cc7333c77043e20c7b0cfc91.zip gdb-a376e11d84ba7ea8cc7333c77043e20c7b0cfc91.tar.gz gdb-a376e11d84ba7ea8cc7333c77043e20c7b0cfc91.tar.bz2 |
Fix calling ifunc functions when resolver has debug info and different name
Currently, on Fedora 27 (glibc 2.26), if you try to call strlen in the
inferior you get:
(gdb) p strlen ("hello")
$1 = (size_t (*)(const char *)) 0x7ffff554aac0 <__strlen_avx2>
strlen is an ifunc function, and what we see above is the result of
calling the ifunc resolver in the inferior. That returns a pointer to
the actual target function that implements strlen on my machine. GDB
should have turned around and called the resolver automatically
without the user noticing.
This is was caused by commit:
commit bf223d3e808e6fec9ee165d3d48beb74837796de
Date: Mon Aug 21 11:34:32 2017 +0100
Handle function aliases better (PR gdb/19487, errno printing)
which added the find_function_alias_target call to c-exp.y, to try to
find an alias with debug info for a minsym. For ifunc symbols, that
finds the ifunc's resolver if it has debug info (in the example it's
called "strlen_ifunc"), with the result that GDB calls that as a
regular function.
After this commit, we get now get:
(top-gdb) p strlen ("hello")
'__strlen_avx2' has unknown return type; cast the call to its declared return type
Which is correct, because __strlen_avx2 is written in assembly.
That'll be improved in a following patch, though.
gdb/ChangeLog:
2018-04-26 Pedro Alves <palves@redhat.com>
* c-exp.y (variable production): Skip finding an alias for ifunc
symbols.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/c-exp.y | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3266d7f..e23eeee 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2018-04-26 Pedro Alves <palves@redhat.com> + * c-exp.y (variable production): Skip finding an alias for ifunc + symbols. + +2018-04-26 Pedro Alves <palves@redhat.com> + * elfread.c (elf_rel_plt_read): Look for relocations for .got.plt too. 2018-04-25 Pedro Alves <palves@redhat.com> diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 8dc3c06..e2ea07c 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1081,7 +1081,9 @@ variable: name_not_typename is important for example for "p *__errno_location()". */ symbol *alias_target - = find_function_alias_target (msymbol); + = (msymbol.minsym->type != mst_text_gnu_ifunc + ? find_function_alias_target (msymbol) + : NULL); if (alias_target != NULL) { write_exp_elt_opcode (pstate, OP_VAR_VALUE); |