* [RFC] Make solib-frv.c work in a non-FDPIC environment
@ 2008-11-15 18:46 Kevin Buettner
2008-11-15 22:50 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2008-11-15 18:46 UTC (permalink / raw)
To: gdb-patches
This patch allows solib-frv.c to be used in a non-FDPIC environment.
Such an environment is found when testing a FDPIC multilib using the
FRV simulator. In such an environment, both the interpreter and
loadmap addresses will be zero.
Comments?
* solib-frv.c (fetch_loadmap): Return early when no segments are
found.
(frv_relocate_main_executable): Return early when both interpreter
and executable loadmap addresses are zero.
Index: solib-frv.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-frv.c,v
retrieving revision 1.22
diff -u -p -r1.22 solib-frv.c
--- solib-frv.c 26 Aug 2008 17:30:35 -0000 1.22
+++ solib-frv.c 14 Nov 2008 22:40:25 -0000
@@ -124,6 +124,9 @@ fetch_loadmap (CORE_ADDR ldmaddr)
nsegs = extract_unsigned_integer (ext_ldmbuf_partial.nsegs,
sizeof ext_ldmbuf_partial.nsegs);
+ if (nsegs < 0)
+ return NULL;
+
/* Allocate space for the complete (external) loadmap. */
ext_ldmbuf_size = sizeof (struct ext_elf32_fdpic_loadmap)
+ (nsegs - 1) * sizeof (struct ext_elf32_fdpic_loadseg);
@@ -860,16 +863,17 @@ static void
frv_relocate_main_executable (void)
{
int status;
- CORE_ADDR exec_addr;
+ CORE_ADDR exec_addr, interp_addr;
struct int_elf32_fdpic_loadmap *ldm;
struct cleanup *old_chain;
struct section_offsets *new_offsets;
int changed;
struct obj_section *osect;
- status = frv_fdpic_loadmap_addresses (target_gdbarch, 0, &exec_addr);
+ status = frv_fdpic_loadmap_addresses (target_gdbarch,
+ &interp_addr, &exec_addr);
- if (status < 0)
+ if (status < 0 || (exec_addr == 0 && interp_addr == 0))
{
/* Not using FDPIC ABI, so do nothing. */
return;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Make solib-frv.c work in a non-FDPIC environment
2008-11-15 18:46 [RFC] Make solib-frv.c work in a non-FDPIC environment Kevin Buettner
@ 2008-11-15 22:50 ` Daniel Jacobowitz
2008-11-20 2:02 ` Kevin Buettner
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-11-15 22:50 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
On Fri, Nov 14, 2008 at 04:21:03PM -0700, Kevin Buettner wrote:
> + if (nsegs < 0)
> + return NULL;
> +
> /* Allocate space for the complete (external) loadmap. */
> ext_ldmbuf_size = sizeof (struct ext_elf32_fdpic_loadmap)
> + (nsegs - 1) * sizeof (struct ext_elf32_fdpic_loadseg);
<= 0? I realize it's probably OK in practice, assuming
ext_elf32_fdpic_loadmap has a trailing [1] array, but allocating less
than the size of the array would be strange.
Otherwise sounds good.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Make solib-frv.c work in a non-FDPIC environment
2008-11-15 22:50 ` Daniel Jacobowitz
@ 2008-11-20 2:02 ` Kevin Buettner
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2008-11-20 2:02 UTC (permalink / raw)
To: gdb-patches
On Sat, 15 Nov 2008 11:14:43 -0500
Daniel Jacobowitz <drow@false.org> wrote:
> On Fri, Nov 14, 2008 at 04:21:03PM -0700, Kevin Buettner wrote:
> > + if (nsegs < 0)
> > + return NULL;
> > +
> > /* Allocate space for the complete (external) loadmap. */
> > ext_ldmbuf_size = sizeof (struct ext_elf32_fdpic_loadmap)
> > + (nsegs - 1) * sizeof (struct ext_elf32_fdpic_loadseg);
>
> <= 0? I realize it's probably OK in practice, assuming
> ext_elf32_fdpic_loadmap has a trailing [1] array, but allocating less
> than the size of the array would be strange.
I agree.
Here's the version that I committed:
* solib-frv.c (fetch_loadmap): Return early when no segments are
found.
(frv_relocate_main_executable): Return early when both interpreter
and executable loadmap addresses are zero.
Index: solib-frv.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-frv.c,v
retrieving revision 1.22
diff -u -p -r1.22 solib-frv.c
--- solib-frv.c 26 Aug 2008 17:30:35 -0000 1.22
+++ solib-frv.c 19 Nov 2008 21:15:17 -0000
@@ -124,6 +124,9 @@ fetch_loadmap (CORE_ADDR ldmaddr)
nsegs = extract_unsigned_integer (ext_ldmbuf_partial.nsegs,
sizeof ext_ldmbuf_partial.nsegs);
+ if (nsegs <= 0)
+ return NULL;
+
/* Allocate space for the complete (external) loadmap. */
ext_ldmbuf_size = sizeof (struct ext_elf32_fdpic_loadmap)
+ (nsegs - 1) * sizeof (struct ext_elf32_fdpic_loadseg);
@@ -860,16 +863,17 @@ static void
frv_relocate_main_executable (void)
{
int status;
- CORE_ADDR exec_addr;
+ CORE_ADDR exec_addr, interp_addr;
struct int_elf32_fdpic_loadmap *ldm;
struct cleanup *old_chain;
struct section_offsets *new_offsets;
int changed;
struct obj_section *osect;
- status = frv_fdpic_loadmap_addresses (target_gdbarch, 0, &exec_addr);
+ status = frv_fdpic_loadmap_addresses (target_gdbarch,
+ &interp_addr, &exec_addr);
- if (status < 0)
+ if (status < 0 || (exec_addr == 0 && interp_addr == 0))
{
/* Not using FDPIC ABI, so do nothing. */
return;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-19 21:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-15 18:46 [RFC] Make solib-frv.c work in a non-FDPIC environment Kevin Buettner
2008-11-15 22:50 ` Daniel Jacobowitz
2008-11-20 2:02 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox