mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: David Dgien <dgienda125@gmail.com>
To: barebox@lists.infradead.org
Cc: David Dgien <dgienda125@gmail.com>
Subject: [PATCH v2 3/8] module: Fix adding module to list after layout
Date: Mon, 29 Jun 2020 20:38:33 -0400	[thread overview]
Message-ID: <20200630003838.7745-4-dgienda125@gmail.com> (raw)
In-Reply-To: <20200630003838.7745-1-dgienda125@gmail.com>

During load_module(), the 'this_module' section is relocated, but the
pointer to the module struct isn't updated to account account for the
move. Do so before adding the module to the module_list.

As a side effect of properly pointing to the relocated module struct, we
no longer need to manually search for and fixup the init_module symbol,
so remove that code.

Signed-off-by: David Dgien <dgienda125@gmail.com>
---
 common/module.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/common/module.c b/common/module.c
index 829c12000..5ace544e0 100644
--- a/common/module.c
+++ b/common/module.c
@@ -297,13 +297,8 @@ struct module * load_module(void *mod_image, unsigned long len)
 		}
 	}
 
-	for (i = 0; i < numsyms; i++) {
-		if (!strcmp(strtab + sym[i].st_name, MODULE_SYMBOL_PREFIX "init_module")) {
-			printf("found init_module() at 0x%08x\n", sym[i].st_value);
-			module->init = (void *)sym[i].st_value;
-		}
-	}
-
+	/* Module has been moved */
+	module = (void *)sechdrs[modindex].sh_addr;
 	list_add_tail(&module->list, &module_list);
 
 	return module;
@@ -311,8 +306,6 @@ struct module * load_module(void *mod_image, unsigned long len)
 cleanup:
 	if (ptr)
 		free(ptr);
-	if (module)
-		free(module);
 
 	return NULL;
 }
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-06-30  0:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30  0:38 [PATCH v2 0/8] Module and ARM Module updates and fixes David Dgien
2020-06-30  0:38 ` [PATCH v2 1/8] Makefile: Initialize and export KBUILD variables David Dgien
2020-06-30  0:38 ` [PATCH v2 2/8] module: Add init macros to module.h David Dgien
2020-06-30  0:38 ` David Dgien [this message]
2020-06-30  0:38 ` [PATCH v2 4/8] module: Fix module command registration David Dgien
2020-06-30  0:38 ` [PATCH v2 5/8] module: Implement HAVE_MOD_ARCH_SPECIFIC David Dgien
2020-06-30  0:38 ` [PATCH v2 6/8] arm: makefile: Fix compiler flag variable David Dgien
2020-06-30  0:38 ` [PATCH v2 7/8] arm: elf: Add THM relocation types David Dgien
2020-06-30  0:38 ` [PATCH v2 8/8] arm: module: Allow modules outside of bl range David Dgien
2020-07-01  5:21 ` [PATCH v2 0/8] Module and ARM Module updates and fixes Sascha Hauer

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=20200630003838.7745-4-dgienda125@gmail.com \
    --to=dgienda125@gmail.com \
    --cc=barebox@lists.infradead.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