[PATCH v2 2/2] makefiles: Split PE debug sections to separate files.

Rémi Bernon rbernon at codeweavers.com
Wed Oct 2 13:26:25 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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/makedep.c b/tools/makedep.c
index 6d74507661e..4b1d68f71f6 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -3189,6 +3189,7 @@ static void output_module( struct makefile *make )
     struct strarray dep_libs = empty_strarray;
     char *module_path = obj_dir_path( make, make->module );
     char *spec_file = NULL;
+    char const *bfd_format = strstr( crosstarget, "x86_64" ) ? "elf64-x86-64" : "elf32-i386";
     unsigned int i;
 
     if (!make->is_exe) spec_file = src_dir_path( make, replace_extension( make->module, ".dll", ".spec" ));
@@ -3249,6 +3250,9 @@ 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 && !make->is_win16)
+        output( "\tmkdir -p $(@D)/.debug && %s-objcopy -O %s --only-keep-debug"
+                " --file-alignment=4096 $@ $(@D)/.debug/$(@F)\n", crosstarget, bfd_format );
 
     if (spec_file && make->importlib)
     {
-- 
2.23.0




More information about the wine-devel mailing list