[PATCH 2/2] makefiles: Split PE debug sections to separate ELF file

Rémi Bernon rbernon at codeweavers.com
Thu Jul 18 02:55:35 CDT 2019


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 <rbernon at codeweavers.com>
---
 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




More information about the wine-devel mailing list