- /* Use bfd_xxx routines, rather than O/S primitives, do error checking!!
- FIXMEmgo */
- /* Actually should be able to use bfd_get_section_contents now that
- we have a .ldinfo section. */
- fd = fopen (core_bfd->filename, FOPEN_RB);
-
- fread (&coredata, sizeof (struct core_dump), 1, fd);
- fseek (fd, (long)coredata.c_tab, 0);
- fread (&ldinfo, (char*)&ldinfo.ldinfo_filename[0] - (char*)&ldinfo.ldinfo_next,
- 1, fd);
- fscanf (fd, "%s", pathname);
+ alloc = 100;
+ path = bfd_malloc (alloc);
+ if (path == NULL)
+ return false;
+ s = path;
+
+ while (1)
+ {
+ if (bfd_read (s, 1, 1, core_bfd) != 1)
+ {
+ free (path);
+ return false;
+ }
+ if (*s == '\0')
+ break;
+ ++s;
+ if (s == path + alloc)
+ {
+ char *n;
+
+ alloc *= 2;
+ n = bfd_realloc (path, alloc);
+ if (n == NULL)
+ {
+ free (path);
+ return false;
+ }
+ s = n + (path - s);
+ path = n;
+ }
+ }