diff options
author | Alan Hayward <alan.hayward@arm.com> | 2018-10-11 14:47:30 +0100 |
---|---|---|
committer | Alan Hayward <alan.hayward@arm.com> | 2018-11-16 13:45:38 +0000 |
commit | 38a72da0f1d968432ae6a2a9697ba55932dc075e (patch) | |
tree | b25e8c746263a3201b2a32bf60f2bc094eb8f46f /gdb/testsuite/gdb.cp/infcall-nodebug-lib.c | |
parent | cf84fa6bcf514157df8343d32885050bafc396f7 (diff) | |
download | binutils-38a72da0f1d968432ae6a2a9697ba55932dc075e.zip binutils-38a72da0f1d968432ae6a2a9697ba55932dc075e.tar.gz binutils-38a72da0f1d968432ae6a2a9697ba55932dc075e.tar.bz2 |
Aarch64: Fix segfault when casting dummy calls
The following will segfault on aarch64 if foo is in another object,
was compiled as c++ and has no debug symbols:
(gdb) p (int)foo()
This is because aarch64_push_dummy_call determines the return type
of the function and then does not check for null pointer.
A null pointer for the return type means the call has no debug
information. For the code to get here, then the call must have
been cast, otherwise we'd error out sooner. In the case of a
no-debug-info call cast, the return type is the type the user
had cast the call to, but we do not have that information
available here.
However, aarch64_push_dummy_call only requires the return type in
order to calculate lang_struct_return. This information is available
in the return_method enum. The fix is to simply use this instead.
Adds testcase to check calls across objects, with all combinations
of c, c++, debug and no debug.
gdb/ChangeLog:
PR gdb/22736:
* aarch64-tdep.c (aarch64_push_dummy_call): Remove
lang_struct_return code.
gdb/testsuite/ChangeLog:
PR gdb/22736:
* gdb.cp/infcall-nodebug-lib.c: New test.
* gdb.cp/infcall-nodebug-main.c: New test.
* gdb.cp/infcall-nodebug.exp: New file.
Diffstat (limited to 'gdb/testsuite/gdb.cp/infcall-nodebug-lib.c')
-rw-r--r-- | gdb/testsuite/gdb.cp/infcall-nodebug-lib.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/infcall-nodebug-lib.c b/gdb/testsuite/gdb.cp/infcall-nodebug-lib.c new file mode 100644 index 0000000..92746f2 --- /dev/null +++ b/gdb/testsuite/gdb.cp/infcall-nodebug-lib.c @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2018 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +int +foo (void) +{ + return 1; +} |