From 1e14f11b78c973963f9aafeb3ed8c1cd2f0f76f8 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Wed, 14 Mar 2012 02:25:11 +0100 Subject: [PATCH] Improve linker command detection to handle line breaks correctly. --- bin/blhc | 4 ++-- t/logs/bad-multiline | 9 +++++++++ t/logs/good-multiline | 12 ++++++++++++ t/tests.t | 5 +++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/bin/blhc b/bin/blhc index 9c3347c..b99e7dc 100755 --- a/bin/blhc +++ b/bin/blhc @@ -275,8 +275,8 @@ foreach my $line (@input) { my $linker = 0; # Linker commands. - if ($line =~ m{\s-o\s+ # -o - (\\\s+)* # possible line continuation + if ($line =~ m{\s-o # -o + [\s\\]*\s+ # possible line continuation ([A-Za-z0-9_/.-]+/)? # path to file [A-Za-z0-9_-]+ # binary name (no dots!) (\.so([0-9.])*|\.la)? # library (including version) diff --git a/t/logs/bad-multiline b/t/logs/bad-multiline index 490690a..9ecf89b 100644 --- a/t/logs/bad-multiline +++ b/t/logs/bad-multiline @@ -9,6 +9,15 @@ gcc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security\ gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c gcc -Wl,-z,relro -o test test-a.o test-b.o test-c.o\ -ltest +gcc -o\ +test test-c.o test-a.o test-b.o\ + -ltest +gcc -o \ +test test-c.o test-b.o test-a.o\ + +gcc -o \ +test test-b.o test-a.o test-c.c\ + # Multiple commands in a single line. gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c; gcc -D_FORTIFY_SOURCE=2 -c test-b.c diff --git a/t/logs/good-multiline b/t/logs/good-multiline index cc4a90c..e975958 100644 --- a/t/logs/good-multiline +++ b/t/logs/good-multiline @@ -14,6 +14,18 @@ gcc \ test \ test-a.o test-b.o test-c.o \ -ltest +gcc \ + -Wl,-z,relro \ +-o\ +test \ + test-a.o test-b.o test-c.o \ +-ltest +gcc \ + -Wl,-z,relro \ +-o\ + test\ + test-a.o test-b.o test-c.o \ +-ltest # Multiple commands in a single line. gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c; gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c diff --git a/t/tests.t b/t/tests.t index 6013606..939dc8b 100644 --- a/t/tests.t +++ b/t/tests.t @@ -258,6 +258,11 @@ is_blhc 'bad-multiline', '', 4, "CFLAGS missing (-Wformat): gcc \\ -g -O2 -fstack-protector\\ --param=ssp-buffer-size=4 -Wformat-security\\ -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c CFLAGS missing (--param=ssp-buffer-size=4): gcc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security\\ -D_FORTIFY_SOURCE=2\\ -c test-b.c CFLAGS missing (-Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c +LDFLAGS missing (-Wl,-z,relro): gcc -o\\ test test-c.o test-a.o test-b.o\\ -ltest +LDFLAGS missing (-Wl,-z,relro): gcc -o \\ test test-c.o test-b.o test-a.o\\ +CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -o \\ test test-b.o test-a.o test-c.c\\ +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -o \\ test test-b.o test-a.o test-c.c\\ +LDFLAGS missing (-Wl,-z,relro): gcc -o \\ test test-b.o test-a.o test-c.c\\ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -D_FORTIFY_SOURCE=2 -c test-b.c CFLAGS missing (-Wformat-security -Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -D_FORTIFY_SOURCE=2 -c test-a.c -- 2.43.2