public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mjw@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: [PATCH] Add configure --disable-textrelcheck option to enable CC=afl-fuzz on 32bit.
Date: Fri, 28 Nov 2014 00:08:02 +0100	[thread overview]
Message-ID: <1417129682-29070-1-git-send-email-mjw@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5390 bytes --]

Using american fuzzy lop has found a lot of issues. It would be nice to
make using it a bit easier. Our build files make sure that no shared
library uses text relocations, but afl-gcc will insert some on i686.
http://www.akkadia.org/drepper/textrelocs.html

Now CC=afl-gcc ./configure --disable-textrelcheck will allow them so
that afl can instrument the libraries.

Don't try to use or install them except with afl-fuzz. When selinux is
enabled it might prevent loading the libraries with DT_TEXTREL set.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 ChangeLog          | 4 ++++
 config/ChangeLog   | 5 +++++
 config/eu.am       | 8 +++++++-
 configure.ac       | 5 +++++
 libasm/ChangeLog   | 4 ++++
 libasm/Makefile.am | 2 +-
 libdw/ChangeLog    | 4 ++++
 libdw/Makefile.am  | 2 +-
 libelf/ChangeLog   | 4 ++++
 libelf/Makefile.am | 2 +-
 10 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0947608..8eeaa08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-27  Mark Wielaard  <mjw@redhat.com>
+
+	* configure.ac: Add --disable-textrelcheck.
+
 2014-10-06  Mark Wielaard  <mjw@redhat.com>
 
 	* NEWS: New section 0.161. Add dwarf_peel_type.
diff --git a/config/ChangeLog b/config/ChangeLog
index 9ebf14f..a05f552 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-27  Mark Wielaard  <mjw@redhat.com>
+
+	* eu.am: Define textrel_msg, textrel_found and textrel_check based
+	on FATAL_TEXTREL.
+
 2014-08-25  Mark Wielaard  <mjw@redhat.com>
 
 	* elfutils.spec.in: Update for 0.160.
diff --git a/config/eu.am b/config/eu.am
index c3b00e0..faf8add 100644
--- a/config/eu.am
+++ b/config/eu.am
@@ -52,4 +52,10 @@ endif
 
 CLEANFILES = *.gcno *.gcda
 
-textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then exit 1; fi
+textrel_msg = echo "WARNING: TEXTREL found in '$@'"
+if FATAL_TEXTREL
+textrel_found = $(textrel_msg); exit 1
+else
+textrel_found = $(textrel_msg)
+endif
+textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then $(textrel_found); fi
diff --git a/configure.ac b/configure.ac
index 76a172d..9bc83c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -212,6 +212,11 @@ AC_CHECK_LIB([stdc++], [__cxa_demangle], [dnl
 AC_DEFINE([USE_DEMANGLE], [1], [Defined if demangling is enabled])])
 AM_CONDITIONAL(DEMANGLE, test "$ac_cv_lib_stdcpp___cxa_demangle" = yes)
 
+AC_ARG_ENABLE([textrelcheck],
+AS_HELP_STRING([--disable-textrelcheck],
+               [Disable textrelcheck being a fatal error]))
+AM_CONDITIONAL(FATAL_TEXTREL, [test "x$enable_textrelcheck" != "xno"])
+
 dnl The directories with content.
 
 dnl Documentation.
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index 2613610..034a64d 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2014-01127  Mark Wielaard  <mjw@redhat.com>
+
+	* Makefile.am (libasm.so): Use textrel_check.
+
 2014-04-13  Mark Wielaard  <mjw@redhat.com>
 
 	* Makefile.am: Remove !MUDFLAP conditions.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index 3d6a2e5..88c2530 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -66,7 +66,7 @@ libasm.so$(EXEEXT): libasm_pic.a libasm.map
 		-Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
 		-Wl,--soname,$@.$(VERSION) \
 		../libebl/libebl.a ../libelf/libelf.so  $(libasm_so_LDLIBS)
-	if $(READELF) -d $@ | fgrep -q TEXTREL; then exit 1; fi
+	$(textrel_check)
 	ln -fs $@ $@.$(VERSION)
 
 install: install-am libasm.so
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index c199707..bab02e5 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,9 @@
 2014-11-27  Mark Wielaard  <mjw@redhat.com>
 
+	* Makefile.am (libdw.so): Use textrel_check.
+
+2014-11-27  Mark Wielaard  <mjw@redhat.com>
+
 	* dwarf_getcfi_elf.c (getcfi_gnu_eh_frame): Initialize
 	search_table_entries and search_table_encoding.
 
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 852d2c8..7a2a25d 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -113,7 +113,7 @@ libdw.so$(EXEEXT): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
 		-ldl $(zip_LIBS)
-	if $(READELF) -d $@ | fgrep -q TEXTREL; then exit 1; fi
+	$(textrel_check)
 	ln -fs $@ $@.$(VERSION)
 
 install: install-am libdw.so
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 68fb0fc..e03ee09 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-27  Mark Wielaard  <mjw@redhat.com>
+
+	* Makefile.am (libelf.so): Use textrel_check.
+
 2014-11-23  Mark Wielaard  <mjw@redhat.com>
 
 	* elf_getdata_rawchunk.c (elf_getdata_rawchunk): Change signed
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 493e4ec..6888529 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -103,7 +103,7 @@ libelf.so$(EXEEXT): libelf_pic.a libelf.map
 	$(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 		-Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
 		-Wl,--soname,$@.$(VERSION),-z,defs,-z,relro $(libelf_so_LDLIBS)
-	if $(READELF) -d $@ | fgrep -q TEXTREL; then exit 1; fi
+	$(textrel_check)
 	ln -fs $@ $@.$(VERSION)
 
 install: install-am libelf.so
-- 
1.9.3


             reply	other threads:[~2014-11-27 23:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-27 23:08 Mark Wielaard [this message]
2014-12-04 13:40 Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417129682-29070-1-git-send-email-mjw@redhat.com \
    --to=mjw@redhat.com \
    --cc=elfutils-devel@lists.fedorahosted.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).