* [patch] Fixed shared library handling in solib-pa64.c
@ 2008-08-05 22:12 John David Anglin
2008-08-06 13:06 ` Randolph Chung
2008-08-06 14:21 ` Daniel Jacobowitz
0 siblings, 2 replies; 6+ messages in thread
From: John David Anglin @ 2008-08-05 22:12 UTC (permalink / raw)
To: gdb-patches; +Cc: randolph
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 <http://docs.hp.com/en/B2355-60130/dlmodinfo.3C.html>,
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 <dave.anglin@nrc-cnrc.gc.ca>
* 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);
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch] Fixed shared library handling in solib-pa64.c
2008-08-05 22:12 [patch] Fixed shared library handling in solib-pa64.c John David Anglin
@ 2008-08-06 13:06 ` Randolph Chung
2008-08-06 14:21 ` Daniel Jacobowitz
1 sibling, 0 replies; 6+ messages in thread
From: Randolph Chung @ 2008-08-06 13:06 UTC (permalink / raw)
To: John David Anglin; +Cc: gdb-patches
On Tue, Aug 5, 2008 at 3:11 PM, John David Anglin
<dave@hiauly1.hia.nrc.ca> wrote:
> 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.
I'm sure this worked at one point, but if we can rely on the OS
libraries to do the read it does seem like the right thing to do.
Please commit.
randolph
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] Fixed shared library handling in solib-pa64.c
2008-08-05 22:12 [patch] Fixed shared library handling in solib-pa64.c John David Anglin
2008-08-06 13:06 ` Randolph Chung
@ 2008-08-06 14:21 ` Daniel Jacobowitz
2008-08-06 14:59 ` John David Anglin
2008-08-06 18:20 ` [patch] Fix shared library handling in solib-pa64.c (take 2) John David Anglin
1 sibling, 2 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2008-08-06 14:21 UTC (permalink / raw)
To: John David Anglin; +Cc: gdb-patches, randolph
On Tue, Aug 05, 2008 at 06:11:24PM -0400, John David Anglin wrote:
> 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 <http://docs.hp.com/en/B2355-60130/dlmodinfo.3C.html>,
> 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.
Does this really do what you want it to?
Looking at that HP man page, it looks like dlmodinfo will use "its own
data structures" - i.e. GDB's load map, not the debugged program's.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] Fixed shared library handling in solib-pa64.c
2008-08-06 14:21 ` Daniel Jacobowitz
@ 2008-08-06 14:59 ` John David Anglin
2008-08-06 18:20 ` [patch] Fix shared library handling in solib-pa64.c (take 2) John David Anglin
1 sibling, 0 replies; 6+ messages in thread
From: John David Anglin @ 2008-08-06 14:59 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, randolph
> Looking at that HP man page, it looks like dlmodinfo will use "its own
> data structures" - i.e. GDB's load map, not the debugged program's.
You are correct. I was confused by testing on gdb itself. However,
the part to get the info about the dynamic loader may be ok.
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch] Fix shared library handling in solib-pa64.c (take 2)
2008-08-06 14:21 ` Daniel Jacobowitz
2008-08-06 14:59 ` John David Anglin
@ 2008-08-06 18:20 ` John David Anglin
2008-08-06 19:26 ` Daniel Jacobowitz
1 sibling, 1 reply; 6+ messages in thread
From: John David Anglin @ 2008-08-06 18:20 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, randolph
> Does this really do what you want it to?
>
> Looking at that HP man page, it looks like dlmodinfo will use "its own
> data structures" - i.e. GDB's load map, not the debugged program's.
Here's take 2. This one actually works. This shows the result
for a simple program.
...
This GDB was configured as "hppa64-hp-hpux11.00"...
(gdb) info shared
No shared libraries loaded at this time.
(gdb) break main
Breakpoint 1 at 0x40000000000029c8: file main.c, line 4.
(gdb) r
Starting program: /home/gnu/gdb/objdir64/main
warning: Loadable segment ".tbss" outside of ELF segments
warning: Loadable segment ".tbss" outside of ELF segments
Breakpoint 1, main () at main.c:4
4 return 0;
(gdb) info shared
From To Syms Read Shared Object Library
0xc00000000000ac80 0xc0000000000419b4 Yes /usr/lib/pa20_64/dld.sl
0x800003ffeff23538 0x800003ffeffe67f8 Yes /lib/pa20_64/libc.2
0x800003ffefec7150 0x800003ffefec8578 Yes /usr/lib/pa20_64/libdl.1
0x800003ffefec2574 0x800003ffefec2574 Yes /opt/graphics/OpenGL/lib/pa20_64/libogltls.sl
One thing that I have noticed is that the shared libraries are always
forced private which makes them writeable. I recently had a program
which dropped core when the library code was shared but not when they
were private.
On hpux 11, the chatr "+dbg" can be used to make libraries private or
shareable. Possibly, it's not a great idea to always force private
libraries. Detection of this is broken for the som target. The
information is now in the shared library header and not __dld_flags.
On hpux 10, I guess we are stuck with forcing private libraries.
Ok?
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2008-08-06 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* solib-pa64.c (read_dld_descriptor): Return zero if load map is not
setup.
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 6 Aug 2008 17:19:39 -0000
@@ -125,8 +125,8 @@ pa64_target_read_memory (void *buffer, C
This must happen after dld starts running, so we can't do it in
read_dynamic_info. Record the fact that we have loaded the
- descriptor. If the library is archive bound, then return zero, else
- return nonzero. */
+ descriptor. If the library is archive bound or the load map
+ hasn't been setup, then return zero; else return nonzero. */
static int
read_dld_descriptor (void)
@@ -161,6 +161,9 @@ read_dld_descriptor (void)
error (_("Error while reading in load map pointer."));
}
+ if (!dld_cache.load_map)
+ return 0;
+
/* Read in the dld load module descriptor */
if (dlgetmodinfo (-1,
&dld_cache.dld_desc,
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-08-06 19:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-05 22:12 [patch] Fixed shared library handling in solib-pa64.c John David Anglin
2008-08-06 13:06 ` Randolph Chung
2008-08-06 14:21 ` Daniel Jacobowitz
2008-08-06 14:59 ` John David Anglin
2008-08-06 18:20 ` [patch] Fix shared library handling in solib-pa64.c (take 2) John David Anglin
2008-08-06 19:26 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox