public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Markus Metzger <mmetzger@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb, solib-svr4: remove locate_base() Date: Tue, 18 Oct 2022 13:24:47 +0000 (GMT) [thread overview] Message-ID: <20221018132447.BB4243858C50@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=60d09f0a0d8000359b8f1dd14b51e7f013ea9e5c commit 60d09f0a0d8000359b8f1dd14b51e7f013ea9e5c Author: Markus Metzger <markus.t.metzger@intel.com> Date: Fri Mar 11 06:46:15 2022 +0100 gdb, solib-svr4: remove locate_base() Whenever we call locate_base(), we clear info->debug_base directly before the call. Thus, we never cache the base location as locate_base() had intended. Move the svr4_have_link_map_offsets() check into elf_locate_base(), inline locate_base() at all call sites, and remove it. Diff: --- gdb/solib-svr4.c | 62 ++++++++++---------------------------------------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 7e83819a03d..222b9df3c47 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -661,6 +661,9 @@ elf_locate_base (void) struct bound_minimal_symbol msymbol; CORE_ADDR dyn_ptr, dyn_ptr_addr; + if (!svr4_have_link_map_offsets ()) + return 0; + /* Look for DT_MIPS_RLD_MAP first. MIPS executables use this instead of DT_DEBUG, although they sometimes contain an unused DT_DEBUG. */ @@ -718,45 +721,6 @@ elf_locate_base (void) return 0; } -/* Locate the base address of dynamic linker structs. - - For both the SunOS and SVR4 shared library implementations, if the - inferior executable has been linked dynamically, there is a single - address somewhere in the inferior's data space which is the key to - locating all of the dynamic linker's runtime structures. This - address is the value of the debug base symbol. The job of this - function is to find and return that address, or to return 0 if there - is no such address (the executable is statically linked for example). - - For SunOS, the job is almost trivial, since the dynamic linker and - all of it's structures are statically linked to the executable at - link time. Thus the symbol for the address we are looking for has - already been added to the minimal symbol table for the executable's - objfile at the time the symbol file's symbols were read, and all we - have to do is look it up there. Note that we explicitly do NOT want - to find the copies in the shared library. - - The SVR4 version is a bit more complicated because the address - is contained somewhere in the dynamic info section. We have to go - to a lot more work to discover the address of the debug base symbol. - Because of this complexity, we cache the value we find and return that - value on subsequent invocations. Note there is no copy in the - executable symbol tables. */ - -static CORE_ADDR -locate_base (struct svr4_info *info) -{ - /* Check to see if we have a currently valid address, and if so, avoid - doing all this work again and just return the cached address. If - we have no cached address, try to locate it in the dynamic info - section for ELF executables. There's no point in doing any of this - though if we don't have some link map offsets to work with. */ - - if (info->debug_base == 0 && svr4_have_link_map_offsets ()) - info->debug_base = elf_locate_base (); - return info->debug_base; -} - /* Find the first element in the inferior's dynamic link map, and return its address in the inferior. Return zero if the address could not be determined. @@ -844,9 +808,8 @@ svr4_keep_data_in_core (CORE_ADDR vaddr, unsigned long size) info = get_svr4_info (current_program_space); - info->debug_base = 0; - locate_base (info); - if (!info->debug_base) + info->debug_base = elf_locate_base (); + if (info->debug_base == 0) return 0; ldsomap = solib_svr4_r_ldsomap (info); @@ -880,8 +843,8 @@ open_symbol_file_object (int from_tty) return 0; /* Always locate the debug struct, in case it has moved. */ - info->debug_base = 0; - if (locate_base (info) == 0) + info->debug_base = elf_locate_base (); + if (info->debug_base == 0) return 0; /* failed somehow... */ /* First link map member should be the executable. */ @@ -1297,13 +1260,10 @@ svr4_current_sos_direct (struct svr4_info *info) return library_list.head ? library_list.head : svr4_default_sos (info); } - /* Always locate the debug struct, in case it has moved. */ - info->debug_base = 0; - locate_base (info); - /* If we can't find the dynamic linker's base structure, this must not be a dynamically linked executable. Hmm. */ - if (! info->debug_base) + info->debug_base = elf_locate_base (); + if (info->debug_base == 0) return svr4_default_sos (info); /* Assume that everything is a library if the dynamic loader was loaded @@ -1839,8 +1799,8 @@ svr4_handle_solib_event (void) return; /* Always locate the debug struct, in case it moved. */ - info->debug_base = 0; - if (locate_base (info) == 0) + info->debug_base = elf_locate_base (); + if (info->debug_base == 0) { /* It's possible for the reloc_complete probe to be triggered before the linker has set the DT_DEBUG pointer (for example, when the
reply other threads:[~2022-10-18 13:24 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20221018132447.BB4243858C50@sourceware.org \ --to=mmetzger@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).