]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add debuginfo build target
authorNeil Horman <nhorman@openssl.org>
Tue, 13 Aug 2024 19:16:08 +0000 (15:16 -0400)
committerTomas Mraz <tomas@openssl.org>
Wed, 21 Aug 2024 13:50:17 +0000 (15:50 +0200)
In the webinar we are currently producing on debugging openssl
applications, we talk about ways to allow debugable binaries without
having to ship all the debug DWARF information to production systems.

Add an optional target to do that DWARF separation to aid users

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25174)

Configurations/00-base-templates.conf
Configurations/unix-Makefile.tmpl
Configure
INSTALL.md

index d55ecea6dc4a982ea104736dab780c04e5972d0f..86287c3a25a3cff7f4ac6e2dd4605a1726e0f9ab 100644 (file)
@@ -78,6 +78,7 @@ my %targets=(
         AR              => "ar",
         ARFLAGS         => "qc",
         CC              => "cc",
+        OBJCOPY         => "objcopy",
         bin_cflags      =>
             sub {
                 my @flags = ();
index 4c24cae7ab62ee9e0e16b8a66b71fdf24dd5d488..966d8fec898480941719f35801ad17d3ec8bc51d 100644 (file)
@@ -373,6 +373,7 @@ CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
+OBJCOPY={- $config{OBJCOPY} -}
 
 MAKEDEPEND={- $config{makedepcmd} -}
 
@@ -533,6 +534,11 @@ LANG=C
 {- dependmagic('build_programs', 'Build the openssl executables and scripts'); -}: build_programs_nodep
 
 all: build_sw {- "build_docs" if !$disabled{docs}; -} ## Build software and documentation
+debuginfo: $(SHLIBS)
+       @set -e; for i in $(SHLIBS); do \
+               $(OBJCOPY) --only-keep-debug $$i $$i.debug; \
+               $(OBJCOPY) --strip-debug --add-gnu-debuglink=$$i.debug $$i; \
+       done;
 
 ##@ Documentation
 build_generated_pods: $(GENERATED_PODS)
index a6b66df4c4d1c11f2a10481ba4c434217c2a18fe..fff97bd6fc82043f61b91a2172677bd15a8e3329 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -758,6 +758,7 @@ my %user = (
     RANLIB      => env('RANLIB'),
     RC          => env('RC') || env('WINDRES'),
     RCFLAGS     => [ env('RCFLAGS') || () ],
+    OBJCOPY     => undef,
     RM          => undef,
    );
 # Info about what "make variables" may be prefixed with the cross compiler
index c25bec822500d3e0273a0a0d7385506e5d033d7b..63ca4e37a5dc31e5e8558a786b874804389cacef 100644 (file)
@@ -1676,6 +1676,12 @@ described here.  Examine the Makefiles themselves for the full list.
     build_docs
                    Build all documentation components.
 
+    debuginfo
+                    On unix platforms, this target can be used to create .debug
+                    libraries, which separate the DWARF information in the
+                    shared library ELF files into a separate file for use
+                    in post-mortem (core dump) debugging
+
     clean
                    Remove all build artefacts and return the directory to a "clean"
                    state.