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:05:58 +0100 |
commit | 28f4fa4d0540ac6a23930202f39782167667e373 (patch) | |
tree | fe851d3ea6e24366d6826e14b38d277a4430e416 /gdb | |
parent | ca31ab1d675c1e20cee5f8cb213c52e3d7352496 (diff) | |
download | binutils-28f4fa4d0540ac6a23930202f39782167667e373.zip binutils-28f4fa4d0540ac6a23930202f39782167667e373.tar.gz binutils-28f4fa4d0540ac6a23930202f39782167667e373.tar.bz2 |
Fix elf_gnu_ifunc_resolve_by_got buglet
The next patch will add a call to elf_gnu_ifunc_resolve_by_got that
trips on a latent buglet -- the function is writing to its output
parameter even if the address wasn't found, confusing the caller. The
function's intro comment says:
/* Try to find the target resolved function entry address of a STT_GNU_IFUNC
function NAME. If the address is found it is stored to *ADDR_P (if ADDR_P
is not NULL) and the function returns 1. It returns 0 otherwise.
So fix the function accordingly.
gdb/ChangeLog:
2018-04-26 Pedro Alves <palves@redhat.com>
* elfread.c (elf_gnu_ifunc_resolve_by_got): Don't write to *ADDR_P
unless we actually resolved the ifunc.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/elfread.c | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 67e1bab..9de1b10 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2018-04-26 Pedro Alves <palves@redhat.com> + * elfread.c (elf_gnu_ifunc_resolve_by_got): Don't write to *ADDR_P + unless we actually resolved the ifunc. + +2018-04-26 Pedro Alves <palves@redhat.com> + * c-exp.y (variable production): Prefer ifunc minsyms over regular function symbols. * symtab.c (find_gnu_ifunc): New function. diff --git a/gdb/elfread.c b/gdb/elfread.c index 16a692d..42a2c92 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -833,10 +833,12 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p) ¤t_target); addr = gdbarch_addr_bits_remove (gdbarch, addr); - if (addr_p) - *addr_p = addr; if (elf_gnu_ifunc_record_cache (name, addr)) - return 1; + { + if (addr_p != NULL) + *addr_p = addr; + return 1; + } } return 0; |