Skip to content

Commit a5d5662

Browse files
nhormant8m
authored andcommitted
Add debuginfo build target
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 <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> (Merged from openssl#25174)
1 parent 55662b6 commit a5d5662

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

Configurations/00-base-templates.conf

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ my %targets=(
7878
AR => "ar",
7979
ARFLAGS => "qc",
8080
CC => "cc",
81+
OBJCOPY => "objcopy",
8182
bin_cflags =>
8283
sub {
8384
my @flags = ();

Configurations/unix-Makefile.tmpl

+6
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
373373
CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
374374
LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
375375
EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
376+
OBJCOPY={- $config{OBJCOPY} -}
376377

377378
MAKEDEPEND={- $config{makedepcmd} -}
378379

@@ -533,6 +534,11 @@ LANG=C
533534
{- dependmagic('build_programs', 'Build the openssl executables and scripts'); -}: build_programs_nodep
534535

535536
all: build_sw {- "build_docs" if !$disabled{docs}; -} ## Build software and documentation
537+
debuginfo: $(SHLIBS)
538+
@set -e; for i in $(SHLIBS); do \
539+
$(OBJCOPY) --only-keep-debug $$i $$i.debug; \
540+
$(OBJCOPY) --strip-debug --add-gnu-debuglink=$$i.debug $$i; \
541+
done;
536542

537543
##@ Documentation
538544
build_generated_pods: $(GENERATED_PODS)

Configure

+1
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ my %user = (
758758
RANLIB => env('RANLIB'),
759759
RC => env('RC') || env('WINDRES'),
760760
RCFLAGS => [ env('RCFLAGS') || () ],
761+
OBJCOPY => undef,
761762
RM => undef,
762763
);
763764
# Info about what "make variables" may be prefixed with the cross compiler

INSTALL.md

+6
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,12 @@ described here. Examine the Makefiles themselves for the full list.
16761676
build_docs
16771677
Build all documentation components.
16781678

1679+
debuginfo
1680+
On unix platforms, this target can be used to create .debug
1681+
libraries, which separate the DWARF information in the
1682+
shared library ELF files into a separate file for use
1683+
in post-mortem (core dump) debugging
1684+
16791685
clean
16801686
Remove all build artefacts and return the directory to a "clean"
16811687
state.

0 commit comments

Comments
 (0)