All of lore.kernel.org
 help / color / mirror / Atom feed
* Compiling modules question
@ 2004-03-29 20:19 Art Haas
  2004-03-29 20:30 ` David S. Miller
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Art Haas @ 2004-03-29 20:19 UTC (permalink / raw)
  To: sparclinux

Hi.

Here's another question for the list that I've not been able to
answer. When I compile a kernel with modules, the modules all have
problems with undefined symbols like 'udiv', 'urem', etc. As
my machine is a 'v8' machine, my solution to resolving this
problem was to edit the makefile and add '-mcpu=v8' in a couple
of places, and things work fine. But, if I had to run my kernel
on a 'v7' machine, things would fail.

In 'arch/sparc/lib' there are routines that provide the missing
functions, so am I missing some step where this library gets linked
into the building of the module? If not, then these missing
functions must get picked up in libc, correct? My ignorance of how
things work in SparcLinux is showing ...

Thanks in advance for any info you can send my way.

Art Haas
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
@ 2004-03-29 20:30 ` David S. Miller
  2004-03-29 21:19 ` Keith M Wesolowski
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: David S. Miller @ 2004-03-29 20:30 UTC (permalink / raw)
  To: sparclinux

On Mon, 29 Mar 2004 14:19:01 -0600
"Art Haas" <ahaas@airmail.net> wrote:

> Here's another question for the list that I've not been able to
> answer. When I compile a kernel with modules, the modules all have
> problems with undefined symbols like 'udiv', 'urem', etc.

Keith, I thought we had fixed this?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
  2004-03-29 20:30 ` David S. Miller
@ 2004-03-29 21:19 ` Keith M Wesolowski
  2004-03-29 21:29 ` Jason Wever
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Keith M Wesolowski @ 2004-03-29 21:19 UTC (permalink / raw)
  To: sparclinux

On Mon, Mar 29, 2004 at 12:30:43PM -0800, David S. Miller wrote:

> "Art Haas" <ahaas@airmail.net> wrote:
> 
> > Here's another question for the list that I've not been able to
> > answer. When I compile a kernel with modules, the modules all have
> > problems with undefined symbols like 'udiv', 'urem', etc.
> 
> Keith, I thought we had fixed this?

Yes, this was fixed on February 6.  I just checked it again and it
works fine.

Art, where are you getting your sources?

-- 
Keith M Wesolowski

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
  2004-03-29 20:30 ` David S. Miller
  2004-03-29 21:19 ` Keith M Wesolowski
@ 2004-03-29 21:29 ` Jason Wever
  2004-03-29 22:42 ` Keith M Wesolowski
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jason Wever @ 2004-03-29 21:29 UTC (permalink / raw)
  To: sparclinux

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 29 Mar 2004, Keith M Wesolowski wrote:

> Yes, this was fixed on February 6.  I just checked it again and it
> works fine.
> 
> Art, where are you getting your sources?

I see this on modules_install on a ss4 when running a 2.4 or 2.6 kernel 
while building, but the modules themselves load and work fine.

- -- 
Jason Wever
Gentoo/Sparc Co-Team Lead
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAaJUtdKvgdVioq28RAhyQAJ92znjmbvJLW2Ib7vSsiVrNpaXhOgCeOAyN
bY+FpE+WWW3xyPGyHJCreT8=pBGL
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
                   ` (2 preceding siblings ...)
  2004-03-29 21:29 ` Jason Wever
@ 2004-03-29 22:42 ` Keith M Wesolowski
  2004-03-30  0:21 ` Rusty Russell
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Keith M Wesolowski @ 2004-03-29 22:42 UTC (permalink / raw)
  To: sparclinux

On Mon, Mar 29, 2004 at 02:19:01PM -0600, Art Haas wrote:

> Here's another question for the list that I've not been able to
> answer. When I compile a kernel with modules, the modules all have
> problems with undefined symbols like 'udiv', 'urem', etc. As

The problem is with depmod, not with the kernel.  Your modules will
build, load and work fine without any changes.

Rusty, this matches the change to modpost.c from a while back; does it
look OK to you?

--- module-init-tools-3.0-pre9/depmod.c.orig	2004-03-29 14:15:23.760083163 -0800
+++ module-init-tools-3.0-pre9/depmod.c	2004-03-29 14:18:07.074152850 -0800
@@ -106,13 +106,26 @@
 
 static int print_unknown;
 
+#define DOTSYM_PFX "__dot_"
+
 struct module *find_symbol(const char *name, const char *modname, int weak)
 {
 	struct symbol *s;
+	char dotname[64 + sizeof(DOTSYM_PFX)];
 
 	/* For our purposes, .foo matches foo.  PPC64 needs this. */
-	if (name[0] = '.')
+	if (name[0] = '.') {
 		name++;
+		strcpy(dotname, DOTSYM_PFX);
+		strncat(dotname, name, sizeof(dotname) - sizeof(DOTSYM_PFX) - 1);
+		dotname[sizeof(dotname)-1] = 0;
+		/* Sparc32 wants .foo to match __dot_foo, try this first. */
+		for (s = symbolhash[tdb_hash(dotname) % SYMBOL_HASH_SIZE];
+		     s; s=s->next) {
+			if (streq(s->name, dotname))
+				return s->owner;
+		}
+	}
 
 	for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s=s->next) {
 		if (streq(s->name, name))


-- 
Keith M Wesolowski

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
                   ` (3 preceding siblings ...)
  2004-03-29 22:42 ` Keith M Wesolowski
@ 2004-03-30  0:21 ` Rusty Russell
  2004-03-30  1:35 ` Art Haas
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Rusty Russell @ 2004-03-30  0:21 UTC (permalink / raw)
  To: sparclinux

On Tue, 2004-03-30 at 08:42, Keith M Wesolowski wrote:
> On Mon, Mar 29, 2004 at 02:19:01PM -0600, Art Haas wrote:
> 
> > Here's another question for the list that I've not been able to
> > answer. When I compile a kernel with modules, the modules all have
> > problems with undefined symbols like 'udiv', 'urem', etc. As
> 
> The problem is with depmod, not with the kernel.  Your modules will
> build, load and work fine without any changes.
> 
> Rusty, this matches the change to modpost.c from a while back; does it
> look OK to you?

Ick, I missed that change to modpost.c.

I really dislike this approach: we already have the code everywhere to
ignore the first dot, and I'd prefer sparc use that same trick.

ie:

1) make rem, urem, mul, umul, div and udiv aliases to .rem, .urem etc:

   extern int rem(int, int) __attribute__((weak,alias(".rem")));

2) EXPORT_SYMBOL(rem) etc.

3) Check genksyms recognises that prototype (it should).

4) Copy "dedotify" from ppc64 to handle them on load.

The only real downside is the risk that someone else will export
those names, but I think that's pretty unlikely.

I don't have sparc here: if noone wants to do the work I can produce
a patch, but someone will need to test...

Cheers,
Rusty.
-- 
Anyone who quotes me in their signature is an idiot -- Rusty Russell


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
                   ` (4 preceding siblings ...)
  2004-03-30  0:21 ` Rusty Russell
@ 2004-03-30  1:35 ` Art Haas
  2004-03-30  7:43 ` Keith M Wesolowski
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Art Haas @ 2004-03-30  1:35 UTC (permalink / raw)
  To: sparclinux

On Mon, Mar 29, 2004 at 01:19:48PM -0800, Keith M Wesolowski wrote:
> On Mon, Mar 29, 2004 at 12:30:43PM -0800, David S. Miller wrote:
> 
> > "Art Haas" <ahaas@airmail.net> wrote:
> > 
> > > Here's another question for the list that I've not been able to
> > > answer. When I compile a kernel with modules, the modules all have
> > > problems with undefined symbols like 'udiv', 'urem', etc.
> > 
> > Keith, I thought we had fixed this?
> 
> Yes, this was fixed on February 6.  I just checked it again and it
> works fine.
> 
> Art, where are you getting your sources?

I'm pulling the code from Linus's BK tree:

http://linux.bkbits.net/linux-2.5

Art
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
                   ` (5 preceding siblings ...)
  2004-03-30  1:35 ` Art Haas
@ 2004-03-30  7:43 ` Keith M Wesolowski
  2004-03-30  8:03 ` David S. Miller
  2004-03-31  0:18 ` Rusty Russell
  8 siblings, 0 replies; 10+ messages in thread
From: Keith M Wesolowski @ 2004-03-30  7:43 UTC (permalink / raw)
  To: sparclinux

On Tue, Mar 30, 2004 at 10:21:12AM +1000, Rusty Russell wrote:

> I really dislike this approach: we already have the code everywhere to
> ignore the first dot, and I'd prefer sparc use that same trick.

Works for me.  Can we put this sucker to bed for good now?

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/03/29 23:41:46-08:00 wesolows@foobazco.org 
#   [SPARC32]: Update module linking for symbols starting with "."
#   
#   Rusty did not like the __dot_sym approach and suggested instead:
#   
#   1) make rem, urem, mul, umul, div and udiv aliases to .rem, .urem etc:
#   
#      extern int rem(int, int) __attribute__((weak,alias(".rem")));
#   
#   2) EXPORT_SYMBOL(rem) etc.
#   3) Check genksyms recognises that prototype (it should).
#   4) Copy "dedotify" from ppc64 to handle them on load.
#   
#   The only real downside is the risk that someone else will export
#   those names, but I think that's pretty unlikely.
# 
# scripts/modpost.c
#   2004/03/29 23:38:38-08:00 wesolows@foobazco.org +2 -14
#   [SPARC32]: Update module linking for symbols starting with "."
# 
# arch/sparc/kernel/sparc_ksyms.c
#   2004/03/29 23:38:38-08:00 wesolows@foobazco.org +19 -29
#   [SPARC32]: Update module linking for symbols starting with "."
# 
# arch/sparc/kernel/module.c
#   2004/03/29 23:38:38-08:00 wesolows@foobazco.org +13 -5
#   [SPARC32]: Update module linking for symbols starting with "."
# 
diff -Nru a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
--- a/arch/sparc/kernel/module.c	Mon Mar 29 23:42:11 2004
+++ b/arch/sparc/kernel/module.c	Mon Mar 29 23:42:11 2004
@@ -36,7 +36,9 @@
            table entries. */
 }
 
-/* Make generic code ignore STT_REGISTER dummy undefined symbols.  */
+/* Make generic code ignore STT_REGISTER dummy undefined symbols,
+ * and replace references to .func with func as in ppc64's dedotify.
+ */
 int module_frob_arch_sections(Elf_Ehdr *hdr,
 			      Elf_Shdr *sechdrs,
 			      char *secstrings,
@@ -44,7 +46,7 @@
 {
 	unsigned int symidx;
 	Elf32_Sym *sym;
-	const char *strtab;
+	char *strtab;
 	int i;
 
 	for (symidx = 0; sechdrs[symidx].sh_type != SHT_SYMTAB; symidx++) {
@@ -57,9 +59,15 @@
 	strtab = (char *)sechdrs[sechdrs[symidx].sh_link].sh_addr;
 
 	for (i = 1; i < sechdrs[symidx].sh_size / sizeof(Elf_Sym); i++) {
-		if (sym[i].st_shndx = SHN_UNDEF &&
-		    ELF32_ST_TYPE(sym[i].st_info) = STT_REGISTER)
-			sym[i].st_shndx = SHN_ABS;
+		if (sym[i].st_shndx = SHN_UNDEF) {
+			if (ELF32_ST_TYPE(sym[i].st_info) = STT_REGISTER)
+				sym[i].st_shndx = SHN_ABS;
+			else {
+				char *name = strtab + sym[i].st_name;
+				if (name[0] = '.')
+					memmove(name, name+1, strlen(name));
+			}
+		}
 	}
 	return 0;
 }
diff -Nru a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
--- a/arch/sparc/kernel/sparc_ksyms.c	Mon Mar 29 23:42:11 2004
+++ b/arch/sparc/kernel/sparc_ksyms.c	Mon Mar 29 23:42:11 2004
@@ -92,31 +92,21 @@
 extern void ___clear_bit(void);
 extern void ___change_bit(void);
 
-/* One thing to note is that the way the symbols of the mul/div
- * support routines are named is a mess, they all start with
- * a '.' which makes it a bitch to export, here is the trick:
+/* Alias functions whose names begin with "." and export the aliases.
+ * The module references will be fixed up by module_frob_arch_sections.
  */
+#define DOT_ALIAS2(__ret, __x, __arg1, __arg2) \
+	extern __ret __x(__arg1, __arg2) \
+	             __attribute__((weak, alias("." # __x)));
+
+DOT_ALIAS2(int, div, int, int)
+DOT_ALIAS2(int, mul, int, int)
+DOT_ALIAS2(int, rem, int, int)
+DOT_ALIAS2(unsigned, udiv, unsigned, unsigned)
+DOT_ALIAS2(unsigned, umul, unsigned, unsigned)
+DOT_ALIAS2(unsigned, urem, unsigned, unsigned)
 
-/* If the interface of any of these special functions does ever
- * change in an incompatible way, you must modify this.
- */
-#define DOT_PROTO(sym) extern int __dot_##sym(int, int)
-
-#ifdef __GENKSYMS__
-#define EXPORT_SYMBOL_DOT(sym)						\
-	DOT_PROTO(sym);							\
-	EXPORT_SYMBOL(__dot_ ## sym)
-#else /* !__GENKSYMS__ */
-#define EXPORT_SYMBOL_DOT(sym)						\
-	DOT_PROTO(sym) __asm__("." # sym);				\
-	__CRC_SYMBOL(__dot_##sym, "")					\
-	static const char __kstrtab___dot_##sym[]			\
-	__attribute__((section("__ksymtab_strings")))			\
-	= "." #sym;							\
-	static const struct kernel_symbol __ksymtab___dot_##sym		\
-	__attribute__((section("__ksymtab")))				\
-	= { (unsigned long)&__dot_##sym, __kstrtab___dot_##sym }
-#endif
+#undef DOT_ALIAS2
 
 /* used by various drivers */
 EXPORT_SYMBOL(sparc_cpu_model);
@@ -325,12 +315,12 @@
 EXPORT_SYMBOL_NOVERS(__muldi3);
 EXPORT_SYMBOL_NOVERS(__divdi3);
 
-EXPORT_SYMBOL_DOT(rem);
-EXPORT_SYMBOL_DOT(urem);
-EXPORT_SYMBOL_DOT(mul);
-EXPORT_SYMBOL_DOT(umul);
-EXPORT_SYMBOL_DOT(div);
-EXPORT_SYMBOL_DOT(udiv);
+EXPORT_SYMBOL(rem);
+EXPORT_SYMBOL(urem);
+EXPORT_SYMBOL(mul);
+EXPORT_SYMBOL(umul);
+EXPORT_SYMBOL(div);
+EXPORT_SYMBOL(udiv);
 
 #ifdef CONFIG_DEBUG_BUGVERBOSE
 EXPORT_SYMBOL(do_BUG);
diff -Nru a/scripts/modpost.c b/scripts/modpost.c
--- a/scripts/modpost.c	Mon Mar 29 23:42:11 2004
+++ b/scripts/modpost.c	Mon Mar 29 23:42:11 2004
@@ -141,26 +141,14 @@
 	symbolhash[hash] = new;
 }
 
-#define DOTSYM_PFX "__dot_"
-
 struct symbol *
 find_symbol(const char *name)
 {
 	struct symbol *s;
-	char dotname[64 + sizeof(DOTSYM_PFX)];
 
-	/* .foo matches foo.  PPC64 needs this. */
-	if (name[0] = '.') {
+	/* For our purposes, .foo matches foo.  PPC64 needs this. */
+	if (name[0] = '.')
 		name++;
-		strcpy(dotname, DOTSYM_PFX);
-		strncat(dotname, name, sizeof(dotname) - sizeof(DOTSYM_PFX) - 1);
-		dotname[sizeof(dotname)-1] = 0;
-		/* Sparc32 wants .foo to match __dot_foo, try this first. */
-		for (s = symbolhash[tdb_hash(dotname) % SYMBOL_HASH_SIZE]; s; s=s->next) {
-			if (strcmp(s->name, dotname) = 0)
-				return s;
-		}
-	}
 
 	for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s=s->next) {
 		if (strcmp(s->name, name) = 0)


-- 
Keith M Wesolowski

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
                   ` (6 preceding siblings ...)
  2004-03-30  7:43 ` Keith M Wesolowski
@ 2004-03-30  8:03 ` David S. Miller
  2004-03-31  0:18 ` Rusty Russell
  8 siblings, 0 replies; 10+ messages in thread
From: David S. Miller @ 2004-03-30  8:03 UTC (permalink / raw)
  To: sparclinux

On Mon, 29 Mar 2004 23:43:21 -0800
Keith M Wesolowski <wesolows@foobazco.org> wrote:

> On Tue, Mar 30, 2004 at 10:21:12AM +1000, Rusty Russell wrote:
> 
> > I really dislike this approach: we already have the code everywhere to
> > ignore the first dot, and I'd prefer sparc use that same trick.
> 
> Works for me.  Can we put this sucker to bed for good now?

I'm fine with this.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Compiling modules question
  2004-03-29 20:19 Compiling modules question Art Haas
                   ` (7 preceding siblings ...)
  2004-03-30  8:03 ` David S. Miller
@ 2004-03-31  0:18 ` Rusty Russell
  8 siblings, 0 replies; 10+ messages in thread
From: Rusty Russell @ 2004-03-31  0:18 UTC (permalink / raw)
  To: sparclinux

On Tue, 2004-03-30 at 17:43, Keith M Wesolowski wrote:
> On Tue, Mar 30, 2004 at 10:21:12AM +1000, Rusty Russell wrote:
> 
> > I really dislike this approach: we already have the code everywhere to
> > ignore the first dot, and I'd prefer sparc use that same trick.
> 
> Works for me.  Can we put this sucker to bed for good now?

Yep, go.

Thanks!
Rusty.
-- 
Anyone who quotes me in their signature is an idiot -- Rusty Russell


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-03-31  0:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-29 20:19 Compiling modules question Art Haas
2004-03-29 20:30 ` David S. Miller
2004-03-29 21:19 ` Keith M Wesolowski
2004-03-29 21:29 ` Jason Wever
2004-03-29 22:42 ` Keith M Wesolowski
2004-03-30  0:21 ` Rusty Russell
2004-03-30  1:35 ` Art Haas
2004-03-30  7:43 ` Keith M Wesolowski
2004-03-30  8:03 ` David S. Miller
2004-03-31  0:18 ` Rusty Russell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.