From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-patches@sources.redhat.com
Subject: Re: patch: solib_break from _r_debug.r_brk
Date: Thu, 29 Sep 2011 15:15:00 -0000 [thread overview]
Message-ID: <j621ob$lv5$1@dough.gmane.org> (raw)
In-Reply-To: <j61v49$2ee$1@dough.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
I have to re-post the patch afterall.
In recoding it from my internal repository to current HEAD, I replaced
hard coded pointer size with the wrong function: gdbarch_ptr_bit, but
what I really wanted is simply target pointer size:
+ const unsigned ptrsz
+ = builtin_type (target_gdbarch)->builtin_func_ptr->length;
Thanks,
Aleksandar
Change log is still the same:
<date> Aleksandar Ristovski <aristovski@qnx.com>
* solib-svr4.c (svr4_fetch_solib_break_from_r_debug): New.
(enable_break): Use new function.
[-- Attachment #2: solib_break-from-r_brk-201109291101.patch --]
[-- Type: text/x-patch, Size: 2165 bytes --]
Index: gdb/solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.154
diff -u -p -r1.154 solib-svr4.c
--- gdb/solib-svr4.c 30 Aug 2011 02:48:05 -0000 1.154
+++ gdb/solib-svr4.c 29 Sep 2011 15:01:36 -0000
@@ -1181,6 +1181,40 @@ cmp_name_and_sec_flags (asymbol *sym, vo
return (strcmp (sym->name, (const char *) data) == 0
&& (sym->section->flags & (SEC_CODE | SEC_DATA)) != 0);
}
+
+/* Use dynamic linker bfd and try to figure out solib break
+ address using _r_debug.r_brk. It is expected that at this point
+ it is unrelocated filled with relative address of solib
+ break function. This case may happen if solib break function
+ is defined as static in the dynamic linker, and dynamic linker
+ library is completely stripped. */
+
+static CORE_ADDR
+svr4_fetch_solib_break_from_r_debug (bfd *const tmp_bfd,
+ const CORE_ADDR load_addr)
+{
+ const CORE_ADDR r_debug_sym_addr
+ = gdb_bfd_lookup_symbol (tmp_bfd, cmp_name_and_sec_flags,
+ (void *) "_r_debug");
+ const struct link_map_offsets *const lmo = svr4_fetch_link_map_offsets ();
+ const unsigned ptrsz
+ = builtin_type (target_gdbarch)->builtin_func_ptr->length;
+ gdb_byte r_brk_addr[ptrsz];
+
+ if (target_read_memory (load_addr + r_debug_sym_addr + lmo->r_brk_offset,
+ r_brk_addr, ptrsz) == 0)
+ {
+ const enum bfd_endian byte_order
+ = gdbarch_byte_order (target_gdbarch);
+
+ return extract_unsigned_integer (r_brk_addr, ptrsz, byte_order);
+ }
+ return 0;
+}
+
+
+
+
/* Arrange for dynamic linker to hit breakpoint.
Both the SunOS and the SVR4 dynamic linkers have, as part of their
@@ -1435,6 +1469,11 @@ enable_break (struct svr4_info *info, in
break;
}
+ /* Failing the above methods of locating debug base, use
+ _r_debug.r_brk structure. */
+ if (sym_addr == 0 && load_addr_found)
+ sym_addr = svr4_fetch_solib_break_from_r_debug (tmp_bfd, load_addr);
+
if (sym_addr != 0)
/* Convert 'sym_addr' from a function pointer to an address.
Because we pass tmp_bfd_target instead of the current
next prev parent reply other threads:[~2011-09-29 15:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-29 13:57 Aleksandar Ristovski
2011-09-29 14:04 ` Marek Polacek
2011-09-29 14:32 ` Aleksandar Ristovski
2011-09-29 15:15 ` Aleksandar Ristovski [this message]
2011-10-03 19:51 ` Aleksandar Ristovski
2011-10-03 20:12 ` Tom Tromey
2011-10-03 20:40 ` Aleksandar Ristovski
2011-10-04 16:58 ` Tom Tromey
2011-10-04 17:59 ` Aleksandar Ristovski
2011-10-10 2:32 ` Daniel Jacobowitz
2011-10-12 21:16 ` Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='j621ob$lv5$1@dough.gmane.org' \
--to=aristovski@qnx.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox