From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 378 invoked by alias); 5 Aug 2008 22:12:04 -0000 Received: (qmail 369 invoked by uid 22791); 5 Aug 2008 22:12:02 -0000 X-Spam-Check-By: sourceware.org Received: from hiauly1.hia.nrc.ca (HELO hiauly1.hia.nrc.ca) (132.246.100.193) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 05 Aug 2008 22:11:28 +0000 Received: by hiauly1.hia.nrc.ca (Postfix, from userid 1000) id A7C2F4E4A; Tue, 5 Aug 2008 18:11:25 -0400 (EDT) Subject: [patch] Fixed shared library handling in solib-pa64.c To: gdb-patches@sourceware.org Date: Tue, 05 Aug 2008 22:12:00 -0000 From: "John David Anglin" Cc: randolph@tausq.org X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20080805221125.A7C2F4E4A@hiauly1.hia.nrc.ca> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00094.txt.bz2 The change below fixes the problem referred to in the NEWS file regarding the hppa64-hp-hpux11* target. The problem was a NULL load map pointer was being passed in the dlgetmodinfo and dlgetname calls. This was causing pa64_target_read_memory() to return 0, and as a result the dlgetmodinfo call was failing. It's not entirely clear why the code to find the load map was failing but I believe it is because the dynamic loader had not initialized the map at the time the call to find the map was made. As described here , it is not necessary to supply a memory read function for the calls to dlgetmodinfo and dlgetname. This causes the dynamic loader to use its own data structures to find the correct module. Getting rid of the code to find the load map results in some simplification. Please install if ok. Thanks, Dave -- J. David Anglin dave.anglin@nrc-cnrc.gc.ca National Research Council of Canada (613) 990-0752 (FAX: 952-6602) 2008-08-05 John David Anglin * solib-pa64.c (dld_cache_t): Remove load_map and load_map_addr fileds. (pa64_target_read_memory): Delete. (read_dld_descriptor): Don't read load map pointer. Don't specify memory read function in call to dlgetmodinfo. (read_dynamic_info): Don't handle DT_HP_LOAD_MAP. (pa64_current_sos): Don't specify memory read function in dlgetmodinfo and dlgetname calls. (pa64_open_symbol_file_object): Likewise. Index: solib-pa64.c =================================================================== RCS file: /cvs/src/src/gdb/solib-pa64.c,v retrieving revision 1.10 diff -u -3 -p -r1.10 solib-pa64.c --- solib-pa64.c 1 Jan 2008 22:53:13 -0000 1.10 +++ solib-pa64.c 5 Aug 2008 21:11:29 -0000 @@ -66,8 +66,6 @@ typedef struct struct bfd_section *dyninfo_sect; int have_read_dld_descriptor; int is_valid; - CORE_ADDR load_map; - CORE_ADDR load_map_addr; struct load_module_desc dld_desc; } dld_cache_t; @@ -111,16 +109,6 @@ pa64_clear_solib (void) { } -/* Wrapper for target_read_memory for dlgetmodinfo. */ - -static void * -pa64_target_read_memory (void *buffer, CORE_ADDR ptr, size_t bufsiz, int ident) -{ - if (target_read_memory (ptr, buffer, bufsiz) != 0) - return 0; - return buffer; -} - /* Read the dynamic linker's internal shared library descriptor. This must happen after dld starts running, so we can't do it in @@ -152,22 +140,9 @@ read_dld_descriptor (void) error (_("Unable to read in .dynamic section information.")); } - /* Read the load map pointer. */ - if (target_read_memory (dld_cache.load_map_addr, - (char *) &dld_cache.load_map, - sizeof (dld_cache.load_map)) - != 0) - { - error (_("Error while reading in load map pointer.")); - } - /* Read in the dld load module descriptor */ - if (dlgetmodinfo (-1, - &dld_cache.dld_desc, - sizeof (dld_cache.dld_desc), - pa64_target_read_memory, - 0, - dld_cache.load_map) + if (dlgetmodinfo (-1, &dld_cache.dld_desc, sizeof (dld_cache.dld_desc), + 0, 0, 0) == 0) { error (_("Error trying to get information about dynamic linker.")); @@ -231,19 +206,6 @@ read_dynamic_info (asection *dyninfo_sec error (_("Error while reading in .dynamic section of the program.")); } } - else if (dyn_tag == DT_HP_LOAD_MAP) - { - /* Dld will place the address of the load map at load_map_addr - after it starts running. */ - if (target_read_memory (entry_addr + offsetof(Elf64_Dyn, - d_un.d_ptr), - (char*) &dld_cache_p->load_map_addr, - sizeof (dld_cache_p->load_map_addr)) - != 0) - { - error (_("Error while reading in .dynamic section of the program.")); - } - } else { /* tag is not of interest */ @@ -256,7 +218,7 @@ read_dynamic_info (asection *dyninfo_sec /* Verify that we read in required info. These fields are re-set to zero in pa64_solib_restart. */ - if (dld_cache_p->dld_flags_addr != 0 && dld_cache_p->load_map_addr != 0) + if (dld_cache_p->dld_flags_addr != 0) dld_cache_p->is_valid = 1; else return 0; @@ -468,15 +430,11 @@ pa64_current_sos (void) continue; /* Read in the load module descriptor. */ - if (dlgetmodinfo (dll_index, &dll_desc, sizeof (dll_desc), - pa64_target_read_memory, 0, dld_cache.load_map) - == 0) + if (dlgetmodinfo (dll_index, &dll_desc, sizeof (dll_desc), 0, 0, 0) == 0) break; /* Get the name of the shared library. */ - dll_path = (char *)dlgetname (&dll_desc, sizeof (dll_desc), - pa64_target_read_memory, - 0, dld_cache.load_map); + dll_path = (char *)dlgetname (&dll_desc, sizeof (dll_desc), 0, 0, 0); new = (struct so_list *) xmalloc (sizeof (struct so_list)); memset (new, 0, sizeof (struct so_list)); @@ -535,14 +493,11 @@ pa64_open_symbol_file_object (void *from return 0; /* Read in the load module descriptor. */ - if (dlgetmodinfo (0, &dll_desc, sizeof (dll_desc), - pa64_target_read_memory, 0, dld_cache.load_map) == 0) + if (dlgetmodinfo (0, &dll_desc, sizeof (dll_desc), 0, 0, 0) == 0) return 0; /* Get the name of the shared library. */ - dll_path = (char *)dlgetname (&dll_desc, sizeof (dll_desc), - pa64_target_read_memory, - 0, dld_cache.load_map); + dll_path = (char *)dlgetname (&dll_desc, sizeof (dll_desc), 0, 0, 0); /* Have a pathname: read the symbol file. */ symbol_file_add_main (dll_path, from_tty);