Linux-kernel mailing list archive 1997-11,: A gdb patch for dynamic linker

# A gdb patch for dynamic linker

H.J. Lu (hjl@lucon.org)
Sun, 23 Nov 1997 13:01:08 -0800 (PST)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Michael Elizabeth Chastain: "New smart CONFIG_* patch, works with modules"
- Previous message: Lorenzo M. Catucci: "CD/ROM automount/unmount and autofs"

Hi,

The newer Linux kernel may load the dynamic linker anywhere it finds
a place for it. As the result,

# gdb ld.so

doesn't work under newer linux kernel when it tries to insert the
break point in the dynamic linker using the address found in the
dynamic linker binary since the kernel may not load the dynamic
linker at address 0. This patch seems to fix this problem.

Thanks.

    --
    H.J. Lu (hjl@gnu.org)

    ---
    Sun Nov 23 12:45:26 1997  H.J. Lu  (hjl@gnu.org)

    	* solib.c (enable_break): Find and use the load address when
    	debugging a dynamic linker for SVR4 shared library.

    --- gdb-970817/gdb/solib.c.orig	Sun Mar  9 21:13:53 1997
    +++ gdb-970817/gdb/solib.c	Sun Nov 23 12:53:00 1997
    @@ -1398,6 +1398,7 @@
     enable_break ()
     {
       int success = 0;
    +  CORE_ADDR load_addr = 0;

     #ifndef SVR4_SHARED_LIBS

    @@ -1449,7 +1450,6 @@
         {
           unsigned int interp_sect_size;
           char *buf;
    -      CORE_ADDR load_addr;
           bfd *tmp_bfd;
           CORE_ADDR sym_addr = 0;

    @@ -1508,6 +1508,12 @@
           warning ("Unable to find dynamic linker breakpoint function.");
           warning ("GDB will be unable to debug shared library initializers");
           warning ("and track explicitly loaded dynamic code.");
    +      load_addr = 0;
    +    }
    +  else
    +    {
    +      if (exec_bfd->flags & DYNAMIC)
    +	load_addr = read_pc () - exec_bfd->start_address;
         }
     #endif

    @@ -1520,7 +1526,8 @@
           msymbol = lookup_minimal_symbol (*bkpt_namep, NULL, symfile_objfile);
           if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
     	{
    -	  create_solib_event_breakpoint (SYMBOL_VALUE_ADDRESS (msymbol));
    +	  create_solib_event_breakpoint (load_addr +
    +					 SYMBOL_VALUE_ADDRESS (msymbol));
     	  return 1;
     	}
         }

     Next message: Michael Elizabeth Chastain: "New smart CONFIG_* patch, works with modules"
     Previous message: Lorenzo M. Catucci: "CD/ROM automount/unmount and autofs"