* Re: How to recgnize the local varialble
[not found] <0CEE46EB9C50E44486A861D738D3E20645F9D0A9@rsex2.realsil.com.cn>
@ 2015-04-29 19:59 ` Jan Kratochvil
0 siblings, 0 replies; only message in thread
From: Jan Kratochvil @ 2015-04-29 19:59 UTC (permalink / raw)
To: 高国胜; +Cc: gdb, Phil Muldoon
On Wed, 29 Apr 2015 10:42:07 +0200, é«å½è wrote:
> Accord to the red part,
Please do not depend on the HTML part of mail, it is difficult to display.
> we can get the memory address of the variable i, but how can the injected
> code identify the symbol i ?
So it looks like:
------------------------------------------------------------------------------
void _gdb_expr (struct __gdb_regs *__regs) {
__attribute__ ((unused)) __gdb_uintptr __i_ptr; {
[...]
__i_ptr = __gdb_stack[__gdb_tos];
}
#pragma GCC user_expression
{
#line 1 "gdb command line"
i=20
; } }
------------------------------------------------------------------------------
Starting at that line
#pragma GCC user_expression
GCC starts to ask GDB about any unknown symbols. With
(gdb) set debug compile 1
you can see it as line:
gcc_convert_symbol "i": local symbol
It is the GDB line:
decl = C_CTX (context)->c_ops->build_decl (C_CTX (context),
SYMBOL_NATURAL_NAME (sym),
kind,
sym_type,
symbol_name, addr,
filename, line);
and 'symbol_name' is "__i_ptr" in this case passed as parameter
const char *, /* Argument SUBSTITUTION_NAME. */
How GCC binds the created symbol "i"'s address to the value of the "__i_ptr"
variable is GCC's magic beyond my knowledge.
Jan
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-04-29 19:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <0CEE46EB9C50E44486A861D738D3E20645F9D0A9@rsex2.realsil.com.cn>
2015-04-29 19:59 ` How to recgnize the local varialble Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).