diff options
author | Joshua Lang <joshualang@google.com> | 2016-12-14 23:05:00 -0800 |
---|---|---|
committer | Joshua Lang <joshualang@google.com> | 2017-01-31 15:41:47 -0800 |
commit | 9bf6cbf6dd88777719c5757922aff0190ec46539 (patch) | |
tree | a6fb4e5541581d7bf6925b298bcb3f4910836bc4 /binutils-2.25/bfd | |
parent | 249bab53c3518fccd432baf1447422b25d884732 (diff) | |
download | toolchain_binutils-9bf6cbf6dd88777719c5757922aff0190ec46539.zip toolchain_binutils-9bf6cbf6dd88777719c5757922aff0190ec46539.tar.gz toolchain_binutils-9bf6cbf6dd88777719c5757922aff0190ec46539.tar.bz2 |
Set CodeView pdb path/name to base name
The CodeView pdb path/name field is empty leading windows minidumps to
have empty module paths for the binary. This patch sets the path to the
base name of the binary.
Bug: 33668347
Change-Id: I4138998239b07b54cc36dc2d2e3484c4b63f5435
Diffstat (limited to 'binutils-2.25/bfd')
-rw-r--r-- | binutils-2.25/bfd/libpei.h | 4 | ||||
-rw-r--r-- | binutils-2.25/bfd/peXXigen.c | 40 |
2 files changed, 31 insertions, 13 deletions
diff --git a/binutils-2.25/bfd/libpei.h b/binutils-2.25/bfd/libpei.h index ffcafde..10090f7 100644 --- a/binutils-2.25/bfd/libpei.h +++ b/binutils-2.25/bfd/libpei.h @@ -238,6 +238,7 @@ #define _bfd_XXi_swap_debugdir_in _bfd_pex64i_swap_debugdir_in #define _bfd_XXi_swap_debugdir_out _bfd_pex64i_swap_debugdir_out #define _bfd_XXi_write_codeview_record _bfd_pex64i_write_codeview_record +#define _bfd_XXi_get_codeview_pdb_name _bfd_pex64i_get_codeview_pdb_name #elif defined COFF_WITH_pep @@ -272,6 +273,7 @@ #define _bfd_XXi_swap_debugdir_in _bfd_pepi_swap_debugdir_in #define _bfd_XXi_swap_debugdir_out _bfd_pepi_swap_debugdir_out #define _bfd_XXi_write_codeview_record _bfd_pepi_write_codeview_record +#define _bfd_XXi_get_codeview_pdb_name _bfd_pepi_get_codeview_pdb_name #else /* !COFF_WITH_pep */ @@ -306,6 +308,7 @@ #define _bfd_XXi_swap_debugdir_in _bfd_pei_swap_debugdir_in #define _bfd_XXi_swap_debugdir_out _bfd_pei_swap_debugdir_out #define _bfd_XXi_write_codeview_record _bfd_pei_write_codeview_record +#define _bfd_XXi_get_codeview_pdb_name _bfd_pei_get_codeview_pdb_name #endif /* !COFF_WITH_pep */ @@ -351,6 +354,7 @@ bfd_boolean _bfd_XXi_final_link_postscript (bfd *, struct coff_final_link_info * void _bfd_XXi_swap_debugdir_in (bfd *, void *, void *); unsigned _bfd_XXi_swap_debugdir_out (bfd *, void *, void *); unsigned _bfd_XXi_write_codeview_record (bfd *, file_ptr, CODEVIEW_INFO *); +const char* _bfd_XXi_get_codeview_pdb_name (bfd *); /* The following are needed only for ONE of pe or pei, but don't otherwise vary; peicode.h fixes up ifdefs but we provide the diff --git a/binutils-2.25/bfd/peXXigen.c b/binutils-2.25/bfd/peXXigen.c index dae32f6..7022340 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); } } |