From 9bf6cbf6dd88777719c5757922aff0190ec46539 Mon Sep 17 00:00:00 2001 From: Joshua Lang Date: Wed, 14 Dec 2016 23:05:00 -0800 Subject: 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 --- binutils-2.25/ld/emultempl/pep.em | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'binutils-2.25/ld/emultempl/pep.em') diff --git a/binutils-2.25/ld/emultempl/pep.em b/binutils-2.25/ld/emultempl/pep.em index b24a608..100d4ef 100644 --- a/binutils-2.25/ld/emultempl/pep.em +++ b/binutils-2.25/ld/emultempl/pep.em @@ -1288,6 +1288,9 @@ write_build_id (bfd *abfd) return TRUE; } + const char * pdb_name = _bfd_XXi_get_codeview_pdb_name (abfd); + unsigned int pdb_name_length = strlen(pdb_name); + if (t->build_id.sec->contents == NULL) t->build_id.sec->contents = (unsigned char *) xmalloc (t->build_id.sec->size); contents = t->build_id.sec->contents; @@ -1306,7 +1309,7 @@ write_build_id (bfd *abfd) idd.MajorVersion = 0; idd.MinorVersion = 0; idd.Type = PE_IMAGE_DEBUG_TYPE_CODEVIEW; - idd.SizeOfData = sizeof (CV_INFO_PDB70) + 1; + idd.SizeOfData = sizeof (CV_INFO_PDB70) + pdb_name_length + 1; idd.AddressOfRawData = asec->vma - ib + link_order->offset + sizeof (struct external_IMAGE_DEBUG_DIRECTORY); idd.PointerToRawData = asec->filepos + link_order->offset @@ -1370,12 +1373,12 @@ setup_build_id (bfd *ibfd) t->build_id.style = emit_build_id; t->build_id.sec = s; - /* Section is a fixed size: + /* Section is a variable size: One IMAGE_DEBUG_DIRECTORY entry, of type IMAGE_DEBUG_TYPE_CODEVIEW, pointing at a CV_INFO_PDB70 record containing the build-id, with a - null byte for PdbFileName. */ + null terminated string for PdbFileName. */ s->size = sizeof (struct external_IMAGE_DEBUG_DIRECTORY) - + sizeof (CV_INFO_PDB70) + 1; + + sizeof (CV_INFO_PDB70) + strlen(_bfd_XXi_get_codeview_pdb_name(link_info.output_bfd)) + 1; return TRUE; } -- cgit v1.1