public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
To: linux-kernel@vger.kernel.org, ltp-list@lists.sourceforge.net,
	ltp-coverage@lists.sourceforge.net,
	Andrew Morton <akpm@linux-foundation.org>,
	rusty@rustcorp.com.au
Subject: [RFC PATCH 5/8] module: add function to map address to containing module
Date: Mon, 21 Apr 2008 14:34:39 +0200	[thread overview]
Message-ID: <480C89DF.9090905@de.ibm.com> (raw)

From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>

module_address() maps an address to the module containing it in either
text or data section. Required by the gcov profiling infrastructure to
associate profiling data structures with modules.

Signed-off-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
---
 include/linux/module.h |    1 +
 kernel/module.c        |   23 ++++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

Index: linux-2.6.25/include/linux/module.h
===================================================================
--- linux-2.6.25.orig/include/linux/module.h
+++ linux-2.6.25/include/linux/module.h
@@ -380,6 +380,7 @@ static inline int module_is_live(struct 
 /* Is this address in a module? (second is with no locks, for oops) */
 struct module *module_text_address(unsigned long addr);
 struct module *__module_text_address(unsigned long addr);
+struct module *module_address(unsigned long addr);
 int is_module_address(unsigned long addr);
 
 /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
Index: linux-2.6.25/kernel/module.c
===================================================================
--- linux-2.6.25.orig/kernel/module.c
+++ linux-2.6.25/kernel/module.c
@@ -2527,10 +2527,16 @@ const struct exception_table_entry *sear
 	return e;
 }
 
-/*
- * Is this a valid module address?
+/**
+ * module_address - map an address to the containing module
+ * @addr: address for which the containing module should be searched
+ *
+ * Return the module which contains the address in either text or data
+ * section. Return NULL if no matching module was found. Callers should
+ * be aware that no reference counting is being performed for the returned
+ * module reference.
  */
-int is_module_address(unsigned long addr)
+struct module *module_address(unsigned long addr)
 {
 	struct module *mod;
 
@@ -2539,15 +2545,22 @@ int is_module_address(unsigned long addr
 	list_for_each_entry(mod, &modules, list) {
 		if (within(addr, mod->module_core, mod->core_size)) {
 			preempt_enable();
-			return 1;
+			return mod;
 		}
 	}
 
 	preempt_enable();
 
-	return 0;
+	return NULL;
 }
 
+/*
+ * Is this a valid module address?
+ */
+int is_module_address(unsigned long addr)
+{
+	return module_address(addr) ? 1 : 0;
+}
 
 /* Is this a valid kernel address? */
 struct module *__module_text_address(unsigned long addr)






             reply	other threads:[~2008-04-21 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-21 12:34 Peter Oberparleiter [this message]
2008-04-21 15:40 ` [RFC PATCH 5/8] module: add function to map address to containing module Rusty Russell
2008-04-22 12:40   ` [Ltp-coverage] " Peter Oberparleiter

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=480C89DF.9090905@de.ibm.com \
    --to=peter.oberparleiter@de.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ltp-coverage@lists.sourceforge.net \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=rusty@rustcorp.com.au \
    /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