Index: gdb/solib-svr4.c =================================================================== RCS file: /cvs/src/src/gdb/solib-svr4.c,v retrieving revision 1.94 diff -u -p -r1.94 solib-svr4.c --- gdb/solib-svr4.c 22 Sep 2008 15:20:08 -0000 1.94 +++ gdb/solib-svr4.c 16 Oct 2008 20:49:05 -0000 @@ -534,16 +534,55 @@ scan_dyntag (int dyntag, bfd *abfd, CORE /* Find the start address of the .dynamic section. */ sect = bfd_get_section_by_name (abfd, ".dynamic"); if (sect == NULL) - return 0; - dyn_addr = bfd_section_vma (abfd, sect); + { + /* We do not give up here. We want to see if the bfd has elf info. + Chances are, they do and in that case we can use PT_DYNAMIC segment + header to get to the section address. + Some NTO architectures will strip sections info altogether but + PT_DYNAMIC will be there, if the executable is a dynamic exe. */ + if (abfd->tdata.elf_obj_data != NULL + && abfd->tdata.elf_obj_data->phdr != NULL) + { + /* We calculate everything needed for looping through + dyntags. */ - /* Read in .dynamic from the BFD. We will get the actual value - from memory later. */ - sect_size = bfd_section_size (abfd, sect); - buf = bufstart = alloca (sect_size); - if (!bfd_get_section_contents (abfd, sect, - buf, 0, sect_size)) - return 0; + unsigned int index = 0; + + while (abfd->tdata.elf_obj_data->phdr[index].p_type != PT_NULL + && abfd->tdata.elf_obj_data->phdr[index].p_type != PT_DYNAMIC) + index++; + + if (abfd->tdata.elf_obj_data->phdr[index].p_type != PT_DYNAMIC) + return 0; + + /* Setup sect_size, needed below. */ + sect_size = arch_size * 10; /* Arbitrary size. We assume + there will be at most 10 entries. + The code below will check for + DT_NULL anyway. */ + dyn_addr = abfd->tdata.elf_obj_data->phdr[index].p_vaddr; + buf = bufstart = alloca (sect_size); + /* Read this from memory as oposed to reading section contents + from file. */ + if (target_read_memory (dyn_addr, buf, sect_size) != 0) + return 0; + } + else + return 0; + } + else + { + /* There is .dynamic section, let default code take care of it. */ + dyn_addr = bfd_section_vma (abfd, sect); + + /* Read in .dynamic from the BFD. We will get the actual value + from memory later. */ + sect_size = bfd_section_size (abfd, sect); + buf = bufstart = alloca (sect_size); + if (!bfd_get_section_contents (abfd, sect, + buf, 0, sect_size)) + return 0; + } /* Iterate over BUF and scan for DYNTAG. If found, set PTR and return. */ step = (arch_size == 32) ? sizeof (Elf32_External_Dyn)