This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA] objfiles.c:objfile_relocate: Handle entry_point in section other than .text


No, I never commit without approval and didn't receive any feedback until now.

Is your approval enough or do I have to wait for jimb's feedback ?

> Peter, did you commit this?
> Seems good to me.
> 
> Elena
> 
> 
> Peter.Schauer writes:
>  > GDB is unable to call functions in executables which are compiled with
>  > maxdata > 256 MB on AIX.
>  > A typescript of a failing GDB session is appended below after the
>  > suggested patch.
>  > 
>  > 
>  > The failure is caused due to the peculiar o_entry definition on AIX:
>  > 
>  > o_entry: Specifies the virtual address of the entry point.
>  > For application programs, this virtual address is the address of the function
>  > descriptor. The function descriptor contains the addresses of both the entry
>  > point itself and its TOC anchor.
>  > 
>  > 
>  > bfd_get_start_address() returns the address from o_entry, which means that
>  > we get the address of the entry function descriptor, which usually lives in
>  > the .data segment.
>  > This (eventually relocated) value is used as the return value from
>  > entry_point_address(), which is used for the call dummy breakpoint address.
>  > 
>  > For call dummy purposes, it doesn't matter that we put the breakpoint
>  > at the function descriptor of the entry point and not at the entry point
>  > itself.
>  > 
>  > The problem arises when the .data segment is relocated, as ei.entry_point
>  > is always relocated with SECT_OFF_TEXT.
>  > 
>  > Here is a patch:
>  > 
>  > 	* objfiles.c (objfile_relocate):  Relocate ei.entry_point with
>  > 	its section offset, use SECT_OFF_TEXT only as a fallback.
>  > 
>  > *** ./objfiles.c.orig	Fri Sep 15 21:27:21 2000
>  > --- ./objfiles.c	Mon Oct  9 21:56:01 2000
>  > ***************
>  > *** 642,647 ****
>  > --- 642,659 ----
>  >         (objfile->section_offsets)->offsets[i] = ANOFFSET (new_offsets, i);
>  >     }
>  >   
>  > +   if (objfile->ei.entry_point != ~(CORE_ADDR) 0)
>  > +     {
>  > +       /* Relocate ei.entry_point with its section offset, use SECT_OFF_TEXT
>  > + 	 only as a fallback.  */
>  > +       struct obj_section *s;
>  > +       s = find_pc_section (objfile->ei.entry_point);
>  > +       if (s)
>  > +         objfile->ei.entry_point += ANOFFSET (delta, s->the_bfd_section->index);
>  > +       else
>  > +         objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
>  > +     }
>  > + 
>  >     {
>  >       struct obj_section *s;
>  >       bfd *abfd;
>  > ***************
>  > *** 657,665 ****
>  >         }
>  >     }
>  >   
>  > -   if (objfile->ei.entry_point != ~(CORE_ADDR) 0)
>  > -     objfile->ei.entry_point += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
>  > - 
>  >     if (objfile->ei.entry_func_lowpc != INVALID_ENTRY_LOWPC)
>  >       {
>  >         objfile->ei.entry_func_lowpc += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
>  > --- 669,674 ----
>  > 	
>  > 
>  > Typescript of failing GDB session:
>  > 
>  > pes@limo_2011$ gcc -g -Wl,-bmaxdata:0x20000000 gdb/testsuite/gdb.base/callfuncs.c
>  > pes@limo_2012$ gdb a.out
>  > GNU gdb 20000915
>  > Copyright 2000 Free Software Foundation, Inc.
>  > GDB is free software, covered by the GNU General Public License, and you are
>  > welcome to change it and/or distribute copies of it under certain conditions.
>  > Type "show copying" to see the conditions.
>  > There is absolutely no warranty for GDB.  Type "show warranty" for details.
>  > This GDB was configured as "powerpc-ibm-aix4.3.3.0"...
>  > (gdb) b main
>  > Breakpoint 1 at 0x100012e8: file gdb/testsuite/gdb.base/callfuncs.c, line 356.
>  > (gdb) r
>  > Starting program: /home2/pes/gnu/gdb/gdbnd/devo/a.out
>  > 
>  > Breakpoint 1, main () at gdb/testsuite/gdb.base/callfuncs.c:356
>  > 356       malloc(1);
>  > (gdb) p add(4,5)
>  > warning: Cannot insert breakpoint 0:
>  > Cannot access memory at address 0x20000aa8
>  > 
>  > -- 
>  > Peter Schauer			pes@regent.e-technik.tu-muenchen.de
> 
> 


-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]