public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:paxmark-libs commit in: /
Date: Thu,  8 Sep 2011 23:55:05 +0000 (UTC)	[thread overview]
Message-ID: <5e1ed43892b658d2a022f50d55510343c3a8bb44.blueness@gentoo> (raw)

commit:     5e1ed43892b658d2a022f50d55510343c3a8bb44
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Mon Sep  5 22:17:15 2011 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Mon Sep  5 22:17:15 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=5e1ed438

testdlpax.c: add dlopen test

---
 Makefile.am |   43 ++++++++++++++++++++++++++++++++++++++++++-
 libmypax.c  |    2 --
 testdlpax.c |   17 +++++++++++++++++
 3 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d4f46c8..9edea4e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,8 +1,11 @@
 ACLOCAL_AMFLAGS = -I m4
+AM_CPPFLAGS = -DPLUGIN='"$(libdir)/libmypax.so"'
 
-bin_PROGRAMS = testpax
+bin_PROGRAMS = testpax testdlpax
 testpax_SOURCES = testpax.c
 testpax_LDFLAGS = -lmypax
+testdlpax_SOURCES = testdlpax.c
+testdlpax_LDFLAGS = -ldl
 
 lib_LTLIBRARIES = libmypax.la
 libmypax_la_SOURCES = libmypax.c
@@ -12,6 +15,7 @@ check_SCRIPTS = poc.sh
 poc.sh:
 	@/sbin/ldconfig
 	@echo "================================================================================"
+	@echo "= TESTING DYNAMIC LINKING ======================================================"
 	@echo
 	@/sbin/paxctl -z $(libdir)/libmypax.so $(bindir)/testpax
 	@/sbin/paxctl -M $(libdir)/libmypax.so
@@ -49,4 +53,41 @@ poc.sh:
 	@echo
 	@echo
 	@echo "================================================================================"
+	@echo "= TESTING DLOPENING ============================================================"
+	@echo
+	@/sbin/paxctl -z $(libdir)/libmypax.so $(bindir)/testdlpax
+	@/sbin/paxctl -M $(libdir)/libmypax.so
+	@/sbin/paxctl -M $(bindir)/testdlpax
+	@/sbin/paxctl -Qv $(libdir)/libmypax.so $(bindir)/testdlpax 2>/dev/null
+	@echo
+	$(bindir)/testdlpax
+	@echo
+	@echo "========================================"
+	@echo
+	@/sbin/paxctl -z $(libdir)/libmypax.so $(bindir)/testdlpax
+	@/sbin/paxctl -m $(libdir)/libmypax.so
+	@/sbin/paxctl -M $(bindir)/testdlpax
+	@/sbin/paxctl -Qv $(libdir)/libmypax.so $(bindir)/testdlpax 2>/dev/null
+	@echo
+	$(bindir)/testdlpax
+	@echo
+	@echo "========================================"
+	@echo
+	@/sbin/paxctl -z $(libdir)/libmypax.so $(bindir)/testdlpax
+	@/sbin/paxctl -M $(libdir)/libmypax.so
+	@/sbin/paxctl -m $(bindir)/testdlpax
+	@/sbin/paxctl -Qv $(libdir)/libmypax.so $(bindir)/testdlpax 2>/dev/null
+	@echo
+	$(bindir)/testdlpax
+	@echo
+	@echo "========================================"
+	@echo
+	@/sbin/paxctl -z $(libdir)/libmypax.so $(bindir)/testdlpax
+	@/sbin/paxctl -m $(libdir)/libmypax.so
+	@/sbin/paxctl -m $(bindir)/testdlpax
+	@/sbin/paxctl -Qv $(libdir)/libmypax.so $(bindir)/testdlpax 2>/dev/null
+	@echo
+	$(bindir)/testdlpax
+	@echo
+	@echo "================================================================================"
 

diff --git a/libmypax.c b/libmypax.c
index ab5b0f7..cdb0ff4 100644
--- a/libmypax.c
+++ b/libmypax.c
@@ -1,5 +1,3 @@
-#include <stdio.h>
-#include <stdlib.h>
 #include <sys/mman.h>
 #include <errno.h>
 #include <string.h>

diff --git a/testdlpax.c b/testdlpax.c
new file mode 100644
index 0000000..fde3245
--- /dev/null
+++ b/testdlpax.c
@@ -0,0 +1,17 @@
+#include <dlfcn.h>
+
+#ifndef PLUGIN
+#define PLUGIN "/usr/local/lib/libmypax.so"
+#endif
+
+int
+main() {
+	void *handle;
+	void (*doit)();
+
+	handle = dlopen(PLUGIN, RTLD_LAZY);
+	doit = dlsym(handle, "doit");
+	(*doit)();
+	dlclose(handle);
+	return 0;
+}



             reply	other threads:[~2011-09-08 23:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-08 23:55 Anthony G. Basile [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-09-08 23:55 [gentoo-commits] proj/elfix:paxmark-libs commit in: / Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile
2011-09-08 23:55 Anthony G. Basile

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=5e1ed43892b658d2a022f50d55510343c3a8bb44.blueness@gentoo \
    --to=blueness@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.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