* Problems using EXPORT_SYMBOL with lib/flex_array
@ 2010-12-01 12:05 Alex Bennee
2010-12-01 13:20 ` Alex Bennee
2010-12-02 1:16 ` [patch] flex_array: export symbols to modules David Rientjes
0 siblings, 2 replies; 9+ messages in thread
From: Alex Bennee @ 2010-12-01 12:05 UTC (permalink / raw)
To: lkml
Hi,
I want to be able to use the flex_array functions in my module so I
wanted to EXPORT_SYMBOL the API.
I added the appropriate EXPORT_SYMBOL runes into lib/flex_array.c and
added externs in the header files but after re-building there is still
no sign of them in Module.symvers.
I've done a make clean, reset the whole repo to ensure the tree is
clean from previous builds and I'm still seeing problems. Am I being a
little dim or is there some other magic foo that needs doing to add an
export to a library function?
--
Alex, homepage: http://www.bennee.com/~alex/
http://www.half-llama.co.uk
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Problems using EXPORT_SYMBOL with lib/flex_array
2010-12-01 12:05 Problems using EXPORT_SYMBOL with lib/flex_array Alex Bennee
@ 2010-12-01 13:20 ` Alex Bennee
2010-12-01 16:19 ` Américo Wang
2010-12-02 1:16 ` [patch] flex_array: export symbols to modules David Rientjes
1 sibling, 1 reply; 9+ messages in thread
From: Alex Bennee @ 2010-12-01 13:20 UTC (permalink / raw)
To: lkml
On 1 December 2010 12:05, Alex Bennee <kernel-hacker@bennee.com> wrote:
> Hi,
>
> I want to be able to use the flex_array functions in my module so I
> wanted to EXPORT_SYMBOL the API.
> <snip>
> Am I being a
> little dim or is there some other magic foo that needs doing to add an
> export to a library function?
It turns out for library code there is. If the .o is only included in
the lib-y section then it will never get scanned for exported kernel
symbols. Tweaking the lib/Makefile so obj-y included flex_array.o did
the trick.
I'm unsure if this behaviour is what is wanted?
--
Alex, homepage: http://www.bennee.com/~alex/
http://www.half-llama.co.uk
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Problems using EXPORT_SYMBOL with lib/flex_array
2010-12-01 13:20 ` Alex Bennee
@ 2010-12-01 16:19 ` Américo Wang
2010-12-01 17:33 ` Alex Bennee
0 siblings, 1 reply; 9+ messages in thread
From: Américo Wang @ 2010-12-01 16:19 UTC (permalink / raw)
To: Alex Bennee; +Cc: lkml
On Wed, Dec 01, 2010 at 01:20:30PM +0000, Alex Bennee wrote:
>On 1 December 2010 12:05, Alex Bennee <kernel-hacker@bennee.com> wrote:
>> Hi,
>>
>> I want to be able to use the flex_array functions in my module so I
>> wanted to EXPORT_SYMBOL the API.
>> <snip>
>> Am I being a
>> little dim or is there some other magic foo that needs doing to add an
>> export to a library function?
>
>It turns out for library code there is. If the .o is only included in
>the lib-y section then it will never get scanned for exported kernel
>symbols. Tweaking the lib/Makefile so obj-y included flex_array.o did
>the trick.
>
>I'm unsure if this behaviour is what is wanted?
>
Yes, but not sure about flex_array.o.
Which functions in flex_array.c do you need in your module anyway?
--
Live like a child, think like the god.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Problems using EXPORT_SYMBOL with lib/flex_array
2010-12-01 16:19 ` Américo Wang
@ 2010-12-01 17:33 ` Alex Bennee
0 siblings, 0 replies; 9+ messages in thread
From: Alex Bennee @ 2010-12-01 17:33 UTC (permalink / raw)
To: Américo Wang; +Cc: lkml
On 1 December 2010 16:19, Américo Wang <xiyou.wangcong@gmail.com> wrote:
> On Wed, Dec 01, 2010 at 01:20:30PM +0000, Alex Bennee wrote:
>>On 1 December 2010 12:05, Alex Bennee <kernel-hacker@bennee.com>
wrote:
<snip>
>>Tweaking the lib/Makefile so obj-y included flex_array.o did
>>the trick.
>>
>>I'm unsure if this behaviour is what is wanted?
>
> Yes, but not sure about flex_array.o.
> Which functions in flex_array.c do you need in your module anyway?
I want to use it to store a sparse array of ATM cell re-assembly
buffers for my ATM over Ethernet driver. Using the per-vcc user_back
structure causes problems when stacked with things like br2684.
So I'm currently using flex_array_alloc/free/clear/put although I
exported them all. I would have thought using library functions was
preferable to rolling your own?
I'm open to other suggestions though.
--
Alex, homepage: http://www.bennee.com/~alex/
http://www.half-llama.co.uk
^ permalink raw reply [flat|nested] 9+ messages in thread
* [patch] flex_array: export symbols to modules
2010-12-01 12:05 Problems using EXPORT_SYMBOL with lib/flex_array Alex Bennee
2010-12-01 13:20 ` Alex Bennee
@ 2010-12-02 1:16 ` David Rientjes
2010-12-02 6:30 ` Paul Mundt
1 sibling, 1 reply; 9+ messages in thread
From: David Rientjes @ 2010-12-02 1:16 UTC (permalink / raw)
To: Andrew Morton, Alex Bennee; +Cc: Dave Hansen, linux-kernel
On Wed, 1 Dec 2010, Alex Bennee wrote:
> Hi,
>
> I want to be able to use the flex_array functions in my module so I
> wanted to EXPORT_SYMBOL the API.
>
> I added the appropriate EXPORT_SYMBOL runes into lib/flex_array.c and
> added externs in the header files but after re-building there is still
> no sign of them in Module.symvers.
>
You shouldn't need to add any externs in include/linux/flex_array.h, they
should already be publically declared.
Perhaps you forgot to include linux/module.h in lib/flex_array.c?
flex_array: export symbols to modules
Add EXPORT_SYMBOL() for all publically accessible flex array functions.
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
lib/flex_array.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/lib/flex_array.c b/lib/flex_array.c
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -23,6 +23,7 @@
#include <linux/flex_array.h>
#include <linux/slab.h>
#include <linux/stddef.h>
+#include <linux/module.h>
struct flex_array_part {
char elements[FLEX_ARRAY_PART_SIZE];
@@ -103,6 +104,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
FLEX_ARRAY_BASE_BYTES_LEFT);
return ret;
}
+EXPORT_SYMBOL(flex_array_alloc);
static int fa_element_to_part_nr(struct flex_array *fa,
unsigned int element_nr)
@@ -126,12 +128,14 @@ void flex_array_free_parts(struct flex_array *fa)
for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++)
kfree(fa->parts[part_nr]);
}
+EXPORT_SYMBOL(flex_array_free_parts);
void flex_array_free(struct flex_array *fa)
{
flex_array_free_parts(fa);
kfree(fa);
}
+EXPORT_SYMBOL(flex_array_free);
static unsigned int index_inside_part(struct flex_array *fa,
unsigned int element_nr)
@@ -196,6 +200,7 @@ int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
memcpy(dst, src, fa->element_size);
return 0;
}
+EXPORT_SYMBOL(flex_array_put);
/**
* flex_array_clear - clear element in array at @element_nr
@@ -223,6 +228,7 @@ int flex_array_clear(struct flex_array *fa, unsigned int element_nr)
memset(dst, FLEX_ARRAY_FREE, fa->element_size);
return 0;
}
+EXPORT_SYMBOL(flex_array_clear);
/**
* flex_array_prealloc - guarantee that array space exists
@@ -259,6 +265,7 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start,
}
return 0;
}
+EXPORT_SYMBOL(flex_array_prealloc);
/**
* flex_array_get - pull data back out of the array
@@ -288,6 +295,7 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr)
}
return &part->elements[index_inside_part(fa, element_nr)];
}
+EXPORT_SYMBOL(flex_array_get);
/**
* flex_array_get_ptr - pull a ptr back out of the array
@@ -308,6 +316,7 @@ void *flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr)
return *tmp;
}
+EXPORT_SYMBOL(flex_array_get_ptr);
static int part_is_free(struct flex_array_part *part)
{
@@ -348,3 +357,4 @@ int flex_array_shrink(struct flex_array *fa)
}
return ret;
}
+EXPORT_SYMBOL(flex_array_shrink);
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] flex_array: export symbols to modules
2010-12-02 1:16 ` [patch] flex_array: export symbols to modules David Rientjes
@ 2010-12-02 6:30 ` Paul Mundt
2010-12-02 6:57 ` Américo Wang
2010-12-02 23:44 ` [patch v2] " David Rientjes
0 siblings, 2 replies; 9+ messages in thread
From: Paul Mundt @ 2010-12-02 6:30 UTC (permalink / raw)
To: David Rientjes; +Cc: Andrew Morton, Alex Bennee, Dave Hansen, linux-kernel
On Wed, Dec 01, 2010 at 05:16:05PM -0800, David Rientjes wrote:
> On Wed, 1 Dec 2010, Alex Bennee wrote:
> > I want to be able to use the flex_array functions in my module so I
> > wanted to EXPORT_SYMBOL the API.
> >
> > I added the appropriate EXPORT_SYMBOL runes into lib/flex_array.c and
> > added externs in the header files but after re-building there is still
> > no sign of them in Module.symvers.
>
> You shouldn't need to add any externs in include/linux/flex_array.h, they
> should already be publically declared.
>
> Perhaps you forgot to include linux/module.h in lib/flex_array.c?
>
> flex_array: export symbols to modules
>
> Add EXPORT_SYMBOL() for all publically accessible flex array functions.
>
> Cc: Dave Hansen <dave@linux.vnet.ibm.com>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
> lib/flex_array.c | 10 ++++++++++
> 1 files changed, 10 insertions(+), 0 deletions(-)
>
This will be ineffective so long as flex_array.o remains lib-y. It will
need to be moved to obj-y if modules are to also make use of it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] flex_array: export symbols to modules
2010-12-02 6:57 ` Américo Wang
@ 2010-12-02 6:56 ` Paul Mundt
0 siblings, 0 replies; 9+ messages in thread
From: Paul Mundt @ 2010-12-02 6:56 UTC (permalink / raw)
To: Am??rico Wang
Cc: David Rientjes, Andrew Morton, Alex Bennee, Dave Hansen,
linux-kernel
On Thu, Dec 02, 2010 at 02:57:35PM +0800, Am??rico Wang wrote:
> On Thu, Dec 02, 2010 at 03:30:55PM +0900, Paul Mundt wrote:
> >On Wed, Dec 01, 2010 at 05:16:05PM -0800, David Rientjes wrote:
> >> On Wed, 1 Dec 2010, Alex Bennee wrote:
> >> > I want to be able to use the flex_array functions in my module so I
> >> > wanted to EXPORT_SYMBOL the API.
> >> >
> >> > I added the appropriate EXPORT_SYMBOL runes into lib/flex_array.c and
> >> > added externs in the header files but after re-building there is still
> >> > no sign of them in Module.symvers.
> >>
> >> You shouldn't need to add any externs in include/linux/flex_array.h, they
> >> should already be publically declared.
> >>
> >> Perhaps you forgot to include linux/module.h in lib/flex_array.c?
> >>
> >> flex_array: export symbols to modules
> >>
> >> Add EXPORT_SYMBOL() for all publically accessible flex array functions.
> >>
> >> Cc: Dave Hansen <dave@linux.vnet.ibm.com>
> >> Signed-off-by: David Rientjes <rientjes@google.com>
> >> ---
> >> lib/flex_array.c | 10 ++++++++++
> >> 1 files changed, 10 insertions(+), 0 deletions(-)
> >>
> >This will be ineffective so long as flex_array.o remains lib-y. It will
> >need to be moved to obj-y if modules are to also make use of it.
>
> Not moved, it needs to be added to obj-y.
Wrong, try again. Unless something has recently changed, an object can
not be both lib-y and obj-y. The object needs to be moved for modules to
make use of it, period.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] flex_array: export symbols to modules
2010-12-02 6:30 ` Paul Mundt
@ 2010-12-02 6:57 ` Américo Wang
2010-12-02 6:56 ` Paul Mundt
2010-12-02 23:44 ` [patch v2] " David Rientjes
1 sibling, 1 reply; 9+ messages in thread
From: Américo Wang @ 2010-12-02 6:57 UTC (permalink / raw)
To: Paul Mundt
Cc: David Rientjes, Andrew Morton, Alex Bennee, Dave Hansen,
linux-kernel
On Thu, Dec 02, 2010 at 03:30:55PM +0900, Paul Mundt wrote:
>On Wed, Dec 01, 2010 at 05:16:05PM -0800, David Rientjes wrote:
>> On Wed, 1 Dec 2010, Alex Bennee wrote:
>> > I want to be able to use the flex_array functions in my module so I
>> > wanted to EXPORT_SYMBOL the API.
>> >
>> > I added the appropriate EXPORT_SYMBOL runes into lib/flex_array.c and
>> > added externs in the header files but after re-building there is still
>> > no sign of them in Module.symvers.
>>
>> You shouldn't need to add any externs in include/linux/flex_array.h, they
>> should already be publically declared.
>>
>> Perhaps you forgot to include linux/module.h in lib/flex_array.c?
>>
>> flex_array: export symbols to modules
>>
>> Add EXPORT_SYMBOL() for all publically accessible flex array functions.
>>
>> Cc: Dave Hansen <dave@linux.vnet.ibm.com>
>> Signed-off-by: David Rientjes <rientjes@google.com>
>> ---
>> lib/flex_array.c | 10 ++++++++++
>> 1 files changed, 10 insertions(+), 0 deletions(-)
>>
>This will be ineffective so long as flex_array.o remains lib-y. It will
>need to be moved to obj-y if modules are to also make use of it.
Not moved, it needs to be added to obj-y.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [patch v2] flex_array: export symbols to modules
2010-12-02 6:30 ` Paul Mundt
2010-12-02 6:57 ` Américo Wang
@ 2010-12-02 23:44 ` David Rientjes
1 sibling, 0 replies; 9+ messages in thread
From: David Rientjes @ 2010-12-02 23:44 UTC (permalink / raw)
To: Andrew Morton; +Cc: Paul Mundt, Alex Bennee, Dave Hansen, linux-kernel
Add EXPORT_SYMBOL() for all publically accessible flex array functions
and move to obj-y so that modules may use this library.
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: David Rientjes <rientjes@google.com>
---
v2: moved to obj-y per Paul Mundt's feedback, thanks!
lib/Makefile | 4 ++--
lib/flex_array.c | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/lib/Makefile b/lib/Makefile
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -12,7 +12,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
idr.o int_sqrt.o extable.o prio_tree.o \
sha1.o irq_regs.o reciprocal_div.o argv_split.o \
proportions.o prio_heap.o ratelimit.o show_mem.o \
- is_single_threaded.o plist.o decompress.o flex_array.o
+ is_single_threaded.o plist.o decompress.o
lib-$(CONFIG_MMU) += ioremap.o
lib-$(CONFIG_SMP) += cpumask.o
@@ -21,7 +21,7 @@ lib-y += kobject.o kref.o klist.o
obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
- string_helpers.o gcd.o lcm.o list_sort.o uuid.o
+ string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o
ifeq ($(CONFIG_DEBUG_KOBJECT),y)
CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/flex_array.c b/lib/flex_array.c
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -23,6 +23,7 @@
#include <linux/flex_array.h>
#include <linux/slab.h>
#include <linux/stddef.h>
+#include <linux/module.h>
struct flex_array_part {
char elements[FLEX_ARRAY_PART_SIZE];
@@ -103,6 +104,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
FLEX_ARRAY_BASE_BYTES_LEFT);
return ret;
}
+EXPORT_SYMBOL(flex_array_alloc);
static int fa_element_to_part_nr(struct flex_array *fa,
unsigned int element_nr)
@@ -126,12 +128,14 @@ void flex_array_free_parts(struct flex_array *fa)
for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++)
kfree(fa->parts[part_nr]);
}
+EXPORT_SYMBOL(flex_array_free_parts);
void flex_array_free(struct flex_array *fa)
{
flex_array_free_parts(fa);
kfree(fa);
}
+EXPORT_SYMBOL(flex_array_free);
static unsigned int index_inside_part(struct flex_array *fa,
unsigned int element_nr)
@@ -196,6 +200,7 @@ int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
memcpy(dst, src, fa->element_size);
return 0;
}
+EXPORT_SYMBOL(flex_array_put);
/**
* flex_array_clear - clear element in array at @element_nr
@@ -223,6 +228,7 @@ int flex_array_clear(struct flex_array *fa, unsigned int element_nr)
memset(dst, FLEX_ARRAY_FREE, fa->element_size);
return 0;
}
+EXPORT_SYMBOL(flex_array_clear);
/**
* flex_array_prealloc - guarantee that array space exists
@@ -259,6 +265,7 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start,
}
return 0;
}
+EXPORT_SYMBOL(flex_array_prealloc);
/**
* flex_array_get - pull data back out of the array
@@ -288,6 +295,7 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr)
}
return &part->elements[index_inside_part(fa, element_nr)];
}
+EXPORT_SYMBOL(flex_array_get);
/**
* flex_array_get_ptr - pull a ptr back out of the array
@@ -308,6 +316,7 @@ void *flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr)
return *tmp;
}
+EXPORT_SYMBOL(flex_array_get_ptr);
static int part_is_free(struct flex_array_part *part)
{
@@ -348,3 +357,4 @@ int flex_array_shrink(struct flex_array *fa)
}
return ret;
}
+EXPORT_SYMBOL(flex_array_shrink);
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-12-02 23:45 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-01 12:05 Problems using EXPORT_SYMBOL with lib/flex_array Alex Bennee
2010-12-01 13:20 ` Alex Bennee
2010-12-01 16:19 ` Américo Wang
2010-12-01 17:33 ` Alex Bennee
2010-12-02 1:16 ` [patch] flex_array: export symbols to modules David Rientjes
2010-12-02 6:30 ` Paul Mundt
2010-12-02 6:57 ` Américo Wang
2010-12-02 6:56 ` Paul Mundt
2010-12-02 23:44 ` [patch v2] " David Rientjes
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 NNTP newsgroup(s).