* [RFC] kbuild: Add a binary only .o file to a module
@ 2004-03-01 21:46 Sam Ravnborg
2004-03-01 22:16 ` Sam Ravnborg
2004-03-02 15:21 ` Chris Friesen
0 siblings, 2 replies; 4+ messages in thread
From: Sam Ravnborg @ 2004-03-01 21:46 UTC (permalink / raw)
To: linux-kernel, Linus Torvalds, Andrew Morton
The following patchs enables the following syntax in kbuild makefiles:
module-addobj := binary-only.o
module-y := a.o b.o c.o
This allows for a clean inclusion of binary only .o files in a module.
This is relevant in the rare cases where there is a glue layer between
some proprietary code and the kernel. Nvidia and the RTL8180 is some
recent examples.
This can be done in several other ways as already suggested in on lkml.
But none of them were what I consider 'good enough' - introducing
some spooky rules etc.
Any objections from having this in the kernel?
[Please, please, this is only for 'legal' binary modules - so do not
start the usual 'binary modules should be GPL discussion'].
This is a small step towards better support for external modules.
For RTL8180 my Makefile looks like this now:
EXTRA_CFLAGS = -DRTL_IO_MAP
obj-m := rtl8180.o
rtl8180-y += r8180_if.o r8180_pci_init.o usercopy.o
# Include proprietary binary module
rtl8180-addobj := priv_part.o
Sam
===== scripts/Makefile.build 1.42 vs edited =====
--- 1.42/scripts/Makefile.build Fri Feb 27 06:33:07 2004
+++ edited/scripts/Makefile.build Mon Mar 1 22:35:47 2004
@@ -255,21 +255,29 @@
$(filter $(addprefix $(obj)/, \
$($(subst $(obj)/,,$(@:.o=-objs))) \
$($(subst $(obj)/,,$(@:.o=-y)))), $^)
+
+# Additional binary images may be linked in without any corresponding src.
+# <composite-object>-addobj := <list of .o files>
+# kbuild will check timestamp, and update <composite object>
+# when the binary changes
+link_multi_add = $(addprefix $(src)/,$($(subst $(obj)/,,$(@:.o=-addobj))))
quiet_cmd_link_multi-y = LD $@
-cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
+cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ \
+ $(link_multi_deps) $(link_multi_add)
quiet_cmd_link_multi-m = LD [M] $@
-cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps)
+cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ \
+ $(link_multi_deps) $(link_multi_add)
# We would rather have a list of rules like
# foo.o: $(foo-objs)
# but that's not so easy, so we rather make all composite objects depend
# on the set of all their parts
-$(multi-used-y) : %.o: $(multi-objs-y) FORCE
+$(multi-used-y) : %.o: $(multi-objs-y) $(multi-add-y) FORCE
$(call if_changed,link_multi-y)
-$(multi-used-m) : %.o: $(multi-objs-m) FORCE
+$(multi-used-m) : %.o: $(multi-objs-m) $(multi-add-m) FORCE
$(call if_changed,link_multi-m)
@{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
===== scripts/Makefile.lib 1.23 vs edited =====
--- 1.23/scripts/Makefile.lib Wed Feb 4 06:29:13 2004
+++ edited/scripts/Makefile.lib Mon Mar 1 22:25:48 2004
@@ -54,6 +54,11 @@
multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
multi-objs := $(multi-objs-y) $(multi-objs-m)
+# Build a list of all additional object to add to our composite objects
+# The composite objects depends on these
+multi-add-y := $(foreach m, $(multi-used-y), $($(m:.o=-addobj)))
+multi-add-m := $(foreach m, $(multi-used-m), $($(m:.o=-addobj)))
+
# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live
# in the local directory
subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
@@ -111,6 +116,8 @@
multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
multi-objs-y := $(addprefix $(obj)/,$(multi-objs-y))
multi-objs-m := $(addprefix $(obj)/,$(multi-objs-m))
+multi-add-y := $(addprefix $(obj)/,$(multi-add-y))
+multi-add-m := $(addprefix $(obj)/,$(multi-add-m))
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
host-progs := $(addprefix $(obj)/,$(host-progs))
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [RFC] kbuild: Add a binary only .o file to a module
2004-03-01 21:46 [RFC] kbuild: Add a binary only .o file to a module Sam Ravnborg
@ 2004-03-01 22:16 ` Sam Ravnborg
2004-03-02 15:21 ` Chris Friesen
1 sibling, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2004-03-01 22:16 UTC (permalink / raw)
To: linux-kernel, Linus Torvalds, Andrew Morton
On Mon, Mar 01, 2004 at 10:46:17PM +0100, Sam Ravnborg wrote:
>
> This can be done in several other ways as already suggested in on lkml.
> But none of them were what I consider 'good enough' - introducing
> some spooky rules etc.
Forget it - I realised this is already supported by kbuild in a nice way.
The _shipped functionality can be used here, so the RTL8180 Makefile
now looks like this:
EXTRA_CFLAGS = -DRTL_IO_MAP
obj-m := rtl8180.o
rtl8180-y += r8180_if.o r8180_pci_init.o usercopy.o
rtl8180-y += priv_part.o
And the binary only .o file is named priv_part.o_shipped.
No added complexity to kbuild - but I need to document this somewhere...
Sam
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] kbuild: Add a binary only .o file to a module
2004-03-01 21:46 [RFC] kbuild: Add a binary only .o file to a module Sam Ravnborg
2004-03-01 22:16 ` Sam Ravnborg
@ 2004-03-02 15:21 ` Chris Friesen
2004-03-02 18:31 ` Jeff Garzik
1 sibling, 1 reply; 4+ messages in thread
From: Chris Friesen @ 2004-03-02 15:21 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-kernel, Linus Torvalds, Andrew Morton
Sam Ravnborg wrote:
> Any objections from having this in the kernel?
> [Please, please, this is only for 'legal' binary modules - so do not
> start the usual 'binary modules should be GPL discussion'].
>
> This is a small step towards better support for external modules.
I'll put in a vote for this. Unfortunately we have some hardware for
which the only drivers available use binary blobs.
Chris
--
Chris Friesen | MailStop: 043/33/F10
Nortel Networks | work: (613) 765-0557
3500 Carling Avenue | fax: (613) 765-2986
Nepean, ON K2H 8E9 Canada | email: cfriesen@nortelnetworks.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] kbuild: Add a binary only .o file to a module
2004-03-02 15:21 ` Chris Friesen
@ 2004-03-02 18:31 ` Jeff Garzik
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Garzik @ 2004-03-02 18:31 UTC (permalink / raw)
To: Chris Friesen; +Cc: Sam Ravnborg, linux-kernel, Linus Torvalds, Andrew Morton
Chris Friesen wrote:
> Sam Ravnborg wrote:
>
>> Any objections from having this in the kernel?
>> [Please, please, this is only for 'legal' binary modules - so do not
>> start the usual 'binary modules should be GPL discussion'].
>>
>> This is a small step towards better support for external modules.
>
>
> I'll put in a vote for this. Unfortunately we have some hardware for
> which the only drivers available use binary blobs.
Shouldn't we discourage this practice where feasible? :)
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-03-02 18:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-01 21:46 [RFC] kbuild: Add a binary only .o file to a module Sam Ravnborg
2004-03-01 22:16 ` Sam Ravnborg
2004-03-02 15:21 ` Chris Friesen
2004-03-02 18:31 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox