From d21483572c60a901b17ab5febf537efa89cd26ba Mon Sep 17 00:00:00 2001
From: Simon Ruderich <simon@ruderich.org>
Date: Wed, 28 Feb 2024 08:06:25 +0100
Subject: [PATCH] Support -g3

---
 NEWS        | 2 ++
 bin/blhc    | 3 ++-
 t/logs/good | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index a9ed25d..72f9364 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ Version 0.XX
   Bug #1033027).
 - Fix tests in sid/testing by removing avr32 which is no longer supported
   (Debian Bug #1050942).
+- Accept -g3 instead of -g which enables more debug information (reported in
+  IRC OFTC/#debian-mentors).
 
 
 Version 0.13
diff --git a/bin/blhc b/bin/blhc
index 5bbcae7..97e8e7f 100755
--- a/bin/blhc
+++ b/bin/blhc
@@ -206,7 +206,7 @@ my $file_extension_regex = qr/
 # Expected (hardening) flags. All flags are used as regexps (and compiled to
 # real regexps below for better execution speed).
 my @def_cflags = (
-    '-g',
+    '-g3?',
     '-O(?:2|3)', # keep at index 1, search for @def_cflags_debug to change it
 );
 my @def_cflags_debug = (
@@ -296,6 +296,7 @@ my @flag_refs_all = (
 # Renaming rules for the output so the regex parts are not visible. Also
 # stores string values of flag regexps above, see compile_flag_regexp().
 my %flag_renames = (
+    '-g3?'                         => '-g',
     '-O(?:2|3)'                    => '-O2',
     '-Wformat(?:=2)?'              => '-Wformat',
     '--param[= ]ssp-buffer-size=4' => '--param=ssp-buffer-size=4',
diff --git a/t/logs/good b/t/logs/good
index 9fe2a62..1432160 100644
--- a/t/logs/good
+++ b/t/logs/good
@@ -11,6 +11,7 @@ gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-se
 gcc -g -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-c.c
 gcc -g -O3 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-d.c
 gcc -g -O3 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=3 -c test-e.c
+gcc -g3 -O2 -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=3 -c test-e.c
 gcc -Wl,-z,relro -o test test-a.o test-b.o test-c.o -ltest
 
 # -Wformat-security is implied by -Werror=format-security and no longer used
-- 
2.49.0