public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Kai Germaschewski <kai-germaschewski@uiowa.edu>
Cc: Richard Henderson <rth@twiddle.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: in-kernel linking issues
Date: Tue, 19 Nov 2002 17:26:47 +1100	[thread overview]
Message-ID: <20021119062835.E09A52C05A@lists.samba.org> (raw)
In-Reply-To: Your message of "Mon, 18 Nov 2002 10:46:10 MDT." <Pine.LNX.4.44.0211181040490.24137-100000@chaos.physics.uiowa.edu>

In message <Pine.LNX.4.44.0211181040490.24137-100000@chaos.physics.uiowa.edu> y
ou write:
> On Fri, 15 Nov 2002, Richard Henderson wrote:
> 
> > [...]
> > 
> > 	ld -T z.ld -shared -o z.so z.o
> 
> BTW, this reminds me of something various people and me have been thinking
> about for some time, i.e. postprocessing the .o files to generate the 
> actual module object.

See below, I made it go via ".raw.o" (this code is from the module
alias / device tables patch).  Renaming the .o files to ".mod" or
".kso" is probably cleaner and clearer.

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

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5-bk-devicetable-base/scripts/Makefile.build working-2.5-bk-devicetable/scripts/Makefile.build
--- working-2.5-bk-devicetable-base/scripts/Makefile.build	2002-11-13 18:54:56.000000000 +1100
+++ working-2.5-bk-devicetable/scripts/Makefile.build	2002-11-14 03:41:30.000000000 +1100
@@ -91,7 +91,8 @@ cmd_cc_i_c       = $(CPP) $(c_flags)   -
 quiet_cmd_cc_o_c = CC      $@
 cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
 
-%.o: %.c FORCE
+# Not for modules
+$(sort $(objs-y) $(multi-objs)) %.o: %.c FORCE
 	$(call if_changed_dep,cc_o_c)
 
 quiet_cmd_cc_lst_c = MKLST   $@
@@ -100,6 +101,16 @@ cmd_cc_lst_c       = $(CC) $(c_flags) -g
 %.lst: %.c FORCE
 	$(call if_changed_dep,cc_lst_c)
 
+# Modules need to go via "finishing" step.
+quiet_cmd_modfinish = FINISH   $@
+cmd_modfinish       = sh scripts/modfinish $< $@
+
+$(patsubst %.o,%.raw.o,$(filter-out $(multi-used-m),$(obj-m))): %.raw.o: %.c
+	$(call if_changed_dep,cc_o_c)
+
+$(obj-m): %.o: %.raw.o
+	$(call cmd,modfinish)
+
 # Compile assembler sources (.S)
 # ---------------------------------------------------------------------------
 
@@ -161,7 +172,7 @@ targets += $(L_TARGET)
 endif
 
 #
-# Rule to link composite objects
+# Rule to link composite objects (builtin)
 #
 
 quiet_cmd_link_multi = LD      $@
@@ -174,8 +185,16 @@ cmd_link_multi = $(LD) $(LDFLAGS) $(EXTR
 $(multi-used-y) : %.o: $(multi-objs-y) FORCE
 	$(call if_changed,link_multi)
 
-$(multi-used-m) : %.o: $(multi-objs-m) FORCE
-	$(call if_changed,link_multi)
+#
+# Rule to link composite objects (module)
+#
+
+quiet_cmd_link_mmulti = LD      $@
+cmd_link_mmulti = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(addprefix $(obj)/,$($(subst $(obj)/,,$(@:.raw.o=-objs))) $($(subst $(obj)/,,$(@:.raw.o=-y)))),$^)
+
+# Need finishing step
+$(multi-used-m:.o=.raw.o) : %.raw.o: $(multi-objs-m) FORCE
+	$(call if_changed,link_mmulti)
 
 targets += $(multi-used-y) $(multi-used-m)
 

  reply	other threads:[~2002-11-19  6:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20021114143701.A30355@twiddle.net.suse.lists.linux.kernel>
2002-11-15  4:13 ` in-kernel linking issues Andi Kleen
2002-11-15  4:21   ` Richard Henderson
2002-11-15  8:44   ` Rusty Russell
2002-11-15 10:29     ` Andi Kleen
2002-11-15 12:51     ` Richard Henderson
2002-11-15 13:16       ` Russell King
2002-11-15 22:30         ` Richard Henderson
2002-11-15 21:21       ` Rusty Russell
2002-11-15 22:22         ` Richard Henderson
2002-11-15 22:45           ` Rusty Russell
2002-11-15 23:47             ` Richard Henderson
2002-11-16  6:19               ` Rusty Russell
2002-11-18 16:46       ` Kai Germaschewski
2002-11-19  6:26         ` Rusty Russell [this message]
2002-11-14 22:37 Richard Henderson
2002-11-16  5:47 ` Rusty Russell
2002-11-16 22:51   ` Richard Henderson
     [not found]     ` <20021117130132.AA5352C058@lists.samba.org>
2002-11-17 20:59       ` Richard Henderson

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=20021119062835.E09A52C05A@lists.samba.org \
    --to=rusty@rustcorp.com.au \
    --cc=kai-germaschewski@uiowa.edu \
    --cc=rth@twiddle.net \
    /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