From: Rémi Bernon Subject: [PATCH 2/2] makefiles: Split PE debug sections to separate ELF file Message-Id: <20190718075535.8898-3-rbernon@codeweavers.com> Date: Thu, 18 Jul 2019 09:55:35 +0200 In-Reply-To: <20190718075535.8898-1-rbernon@codeweavers.com> References: <20190718075535.8898-1-rbernon@codeweavers.com> Linux perf tool cannot parse PE files for debug information, but it also looks for external debug info alongside to the binaries it detects. We can use this feature to provide DWARF information for PE files by splitting the sections to a separate ELF that perf will understand. Signed-off-by: Rémi Bernon --- tools/makedep.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/makedep.c b/tools/makedep.c index 9713f62b25d..b5474dc24f5 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -3244,6 +3244,14 @@ static void output_module( struct makefile *make ) output_filename( make->is_cross ? "$(CROSSLDFLAGS)" : "$(LDFLAGS)" ); output_filename( make->is_cross ? "-Wl,--file-alignment,4096" : "" ); output( "\n" ); + if (make->is_cross) + { + output( "ifeq ($(CROSSTARGET),x86_64-w64-mingw32)\n"); + output( "\tmkdir -p $(@D)/.debug && objcopy -O elf64-x86-64 --only-keep-debug --file-alignment=4096 $@ $(@D)/.debug/$(@F)\n" ); + output( "else\n"); + output( "\tmkdir -p $(@D)/.debug && objcopy -O elf32-i386 --only-keep-debug --file-alignment=4096 $@ $(@D)/.debug/$(@F)\n" ); + output( "endif\n"); + } if (spec_file && make->importlib) { -- 2.20.1