- if (regnum == -1 || regnum == i)
- regcache_raw_supply (regcache, i, regs + offset);
+ struct obj_section *sec;
+
+ ALL_OBJFILE_OSECTIONS (faddr_sec->objfile, sec)
+ {
+ if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0)
+ break;
+ }
+
+ if (sec < faddr_sec->objfile->sections_end)
+ {
+ CORE_ADDR addr = obj_section_addr (sec);
+ CORE_ADDR endaddr = obj_section_endaddr (sec);
+
+ while (addr < endaddr)
+ {
+ gdb_byte buf[4];
+ LONGEST tag;
+
+ if (target_read_memory (addr, buf, sizeof buf) != 0)
+ break;
+
+ tag = extract_signed_integer (buf, sizeof buf, byte_order);
+ if (tag == DT_PLTGOT)
+ {
+ CORE_ADDR pltgot;
+
+ if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
+ break;
+
+ /* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so
+ we have to do it ourselves. */
+ pltgot = extract_unsigned_integer (buf, sizeof buf,
+ byte_order);
+ pltgot += ANOFFSET (sec->objfile->section_offsets,
+ SECT_OFF_TEXT (sec->objfile));
+
+ return pltgot;
+ }
+
+ if (tag == DT_NULL)
+ break;
+
+ addr += 8;
+ }
+ }