summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2018-03-25 18:02:46 +0100
committerPedro Alves <palves@redhat.com>2018-04-10 22:52:50 +0100
commit3af5c6c54980be4e8a3d057436f9129ccecb3a6f (patch)
tree9428b744d95d52d62580a4b425ac4253adde7df2
parent3dc5bded8a35031ebdc27e133463560e870d55a1 (diff)
downloadbinutils-gdb-3af5c6c54980be4e8a3d057436f9129ccecb3a6f.tar.gz
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: yyyy-mm-dd 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.
-rw-r--r--gdb/elfread.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 16a692d3713..42a2c92e9c6 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)
&current_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;