summaryrefslogtreecommitdiffstats
path: root/binutils-2.25/bfd/peXXigen.c
diff options
context:
space:
mode:
Diffstat (limited to 'binutils-2.25/bfd/peXXigen.c')
-rw-r--r--binutils-2.25/bfd/peXXigen.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/binutils-2.25/bfd/peXXigen.c b/binutils-2.25/bfd/peXXigen.c
index dae32f66..70223404 100644
--- a/binutils-2.25/bfd/peXXigen.c
+++ b/binutils-2.25/bfd/peXXigen.c
@@ -1138,19 +1138,31 @@ _bfd_XXi_swap_debugdir_out (bfd * abfd, void * inp, void * extp)
return sizeof (struct external_IMAGE_DEBUG_DIRECTORY);
}
+const char *
+_bfd_XXi_get_codeview_pdb_name (bfd * abfd)
+{
+ char * filename_ptr = bfd_get_filename(abfd);
+ char * last_dir_separator = strrchr(filename_ptr, '/');
+ if (last_dir_separator != NULL) {
+ filename_ptr = last_dir_separator+1;
+ }
+ return filename_ptr;
+}
+
static CODEVIEW_INFO *
_bfd_XXi_slurp_codeview_record (bfd * abfd, file_ptr where, unsigned long length, CODEVIEW_INFO *cvinfo)
{
- char buffer[256+1];
- if (bfd_seek (abfd, where, SEEK_SET) != 0)
+ char buffer [length];
+
+ if (!cvinfo)
return NULL;
- if (bfd_bread (buffer, 256, abfd) < 4)
+ if (bfd_seek (abfd, where, SEEK_SET) != 0)
return NULL;
- /* Ensure null termination of filename. */
- buffer[256] = '\0';
+ if (bfd_bread (buffer, length, abfd) < 4)
+ return NULL;
cvinfo->CVSignature = H_GET_32(abfd, buffer);
cvinfo->Age = 0;
@@ -1171,7 +1183,7 @@ _bfd_XXi_slurp_codeview_record (bfd * abfd, file_ptr where, unsigned long length
memcpy (&(cvinfo->Signature[8]), &(cvinfo70->Signature[8]), 8);
cvinfo->SignatureLength = CV_INFO_SIGNATURE_LENGTH;
- // cvinfo->PdbFileName = cvinfo70->PdbFileName;
+ strcpy(cvinfo->PdbFileName, cvinfo70->PdbFileName);
return cvinfo;
}
@@ -1193,7 +1205,9 @@ _bfd_XXi_slurp_codeview_record (bfd * abfd, file_ptr where, unsigned long length
unsigned int
_bfd_XXi_write_codeview_record (bfd * abfd, file_ptr where, CODEVIEW_INFO *cvinfo)
{
- unsigned int size = sizeof (CV_INFO_PDB70) + 1;
+ const char * filename_ptr = _bfd_XXi_get_codeview_pdb_name(abfd);
+ unsigned int filename_size = strlen(filename_ptr);
+ unsigned int size = sizeof (CV_INFO_PDB70) + filename_size + 1;
CV_INFO_PDB70 *cvinfo70;
char buffer[size];
@@ -1211,7 +1225,7 @@ _bfd_XXi_write_codeview_record (bfd * abfd, file_ptr where, CODEVIEW_INFO *cvinf
memcpy (&(cvinfo70->Signature[8]), &(cvinfo->Signature[8]), 8);
H_PUT_32 (abfd, cvinfo->Age, cvinfo70->Age);
- cvinfo70->PdbFileName[0] = '\0';
+ strcpy(cvinfo70->PdbFileName, filename_ptr);
if (bfd_bwrite (buffer, size, abfd) != size)
return 0;
@@ -2655,8 +2669,8 @@ pe_print_debugdata (bfd * abfd, void * vfile)
if (idd.Type == PE_IMAGE_DEBUG_TYPE_CODEVIEW)
{
char signature[CV_INFO_SIGNATURE_LENGTH * 2 + 1];
- char buffer[256 + 1];
- CODEVIEW_INFO *cvinfo = (CODEVIEW_INFO *) buffer;
+ char buffer [idd.SizeOfData];
+ CODEVIEW_INFO * cvinfo = (CODEVIEW_INFO *) buffer;
/* The debug entry doesn't have to have to be in a section,
in which case AddressOfRawData is 0, so always use PointerToRawData. */
@@ -2667,9 +2681,9 @@ pe_print_debugdata (bfd * abfd, void * vfile)
for (i = 0; i < cvinfo->SignatureLength; i++)
sprintf (&signature[i*2], "%02x", cvinfo->Signature[i] & 0xff);
- fprintf (file, "(format %c%c%c%c signature %s age %ld)\n",
- buffer[0], buffer[1], buffer[2], buffer[3],
- signature, cvinfo->Age);
+ fprintf (file, "(format %c%c%c%c signature %s age %ld pdb %s)\n",
+ buffer[0], buffer[1], buffer[2], buffer[3],
+ signature, cvinfo->Age, cvinfo->PdbFileName);
}
}