The introduction of the _SHARED macros had one flaw: If multiple files had _SHARED defined during compilation, each of them would contain an assignment of stage0_printk to *printk. During linking, this caused errors as multiple definitions of printk existed. Make sure _SHARED alone gives you only the printk prototype, and iff _MAINOBJECT is defined as well, include the assignment.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
--- Index: LinuxBIOSv3/include/shared.h =================================================================== --- LinuxBIOSv3/include/shared.h (Revision 515) +++ LinuxBIOSv3/include/shared.h (Arbeitskopie) @@ -29,9 +29,16 @@ */ #define FUNC(func, ret, attr, args...) \ ret stage0_##func(args) attr + +#ifdef _MAINOBJECT #define EXTERN(func, ret, attr, args...) \ ret (*func)(args) attr= stage0_##func #else +#define EXTERN(func, ret, attr, args...) \ + ret *func(args) attr +#endif + +#else #define FUNC(func, ret, attr, args...) \ ret func(args) attr #define EXTERN(func, ret, attr, args...) Index: LinuxBIOSv3/mainboard/adl/msm800sev/Makefile =================================================================== --- LinuxBIOSv3/mainboard/adl/msm800sev/Makefile (Revision 515) +++ LinuxBIOSv3/mainboard/adl/msm800sev/Makefile (Arbeitskopie) @@ -34,7 +34,7 @@
# Next Quest: Make a single rule out of those: $(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c - $(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@ + $(Q)$(CC) $(INITCFLAGS) -D_SHARED -D_MAINOBJECT -fPIE -c $< -o $@ $(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c $(Q)mkdir -p $(dir $@) $(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@ Index: LinuxBIOSv3/mainboard/amd/norwich/Makefile =================================================================== --- LinuxBIOSv3/mainboard/amd/norwich/Makefile (Revision 515) +++ LinuxBIOSv3/mainboard/amd/norwich/Makefile (Arbeitskopie) @@ -28,7 +28,7 @@
# Next Quest: Make a single rule out of those: $(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c - $(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@ + $(Q)$(CC) $(INITCFLAGS) -D_SHARED -D_MAINOBJECT -fPIE -c $< -o $@ $(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c $(Q)mkdir -p $(dir $@) $(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@ Index: LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile =================================================================== --- LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile (Revision 515) +++ LinuxBIOSv3/mainboard/artecgroup/dbe61/Makefile (Arbeitskopie) @@ -32,7 +32,7 @@
# Next Quest: Make a single rule out of those: $(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c - $(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@ + $(Q)$(CC) $(INITCFLAGS) -D_SHARED -D_MAINOBJECT -fPIE -c $< -o $@ $(obj)/northbridge/amd/geodelx/raminit.o: $(src)/northbridge/amd/geodelx/raminit.c $(Q)mkdir -p $(dir $@) $(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@ Index: LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile =================================================================== --- LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile (Revision 515) +++ LinuxBIOSv3/mainboard/emulation/qemu-x86/Makefile (Arbeitskopie) @@ -43,7 +43,7 @@ INITRAM_OBJ = $(obj)/mainboard/$(MAINBOARDDIR)/initram.o
$(obj)/mainboard/$(MAINBOARDDIR)/initram.o: $(src)/mainboard/$(MAINBOARDDIR)/initram.c - $(Q)$(CC) $(INITCFLAGS) -D_SHARED -fPIE -c $< -o $@ + $(Q)$(CC) $(INITCFLAGS) -D_SHARED -D_MAINOBJECT -fPIE -c $< -o $@
$(obj)/linuxbios.initram $(obj)/linuxbios.initram.map: $(obj)/stage0.init $(obj)/stage0-prefixed.o $(INITRAM_OBJ) $(Q)# initram links against stage0
On Thu, Nov 22, 2007 at 09:44:03PM +0100, Carl-Daniel Hailfinger wrote:
The introduction of the _SHARED macros had one flaw: If multiple files had _SHARED defined during compilation, each of them would contain an assignment of stage0_printk to *printk. During linking, this caused errors as multiple definitions of printk existed. Make sure _SHARED alone gives you only the printk prototype, and iff _MAINOBJECT is defined as well, include the assignment.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Great, thanks a lot!
Committed in r516, and I added the commit message as comment too, it's very useful to understand what's going on in that file IMO.
I tested this and can confirm that all v3 targets build fine now.
Uwe.
* Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net [071122 21:44]:
The introduction of the _SHARED macros had one flaw: If multiple files had _SHARED defined during compilation, each of them would contain an assignment of stage0_printk to *printk. During linking, this caused errors as multiple definitions of printk existed. Make sure _SHARED alone gives you only the printk prototype, and iff _MAINOBJECT is defined as well, include the assignment.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
I like it, but I suggest to simplify the code further.
On top of your sign-off, add Signed-off-by: Stefan Reinauer stepan@coresystems.de
* Stefan Reinauer stepan@coresystems.de [071123 00:04]:
- Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net [071122 21:44]:
The introduction of the _SHARED macros had one flaw: If multiple files had _SHARED defined during compilation, each of them would contain an assignment of stage0_printk to *printk. During linking, this caused errors as multiple definitions of printk existed. Make sure _SHARED alone gives you only the printk prototype, and iff _MAINOBJECT is defined as well, include the assignment.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
I like it, but I suggest to simplify the code further.
Uwe was faster. So here's the diff without Carl-Daniel's patch
it gets rid of the per-file rules for initram code completely.
Patch is Signed-off-by: Stefan Reinauer stepan@coresystems.de
I think we should go even further and specify the INITRAM_SOURCE instead of INITRAM_OBJ because those are the files we care about. (And it will make proper dependencies easier at some point)
On Fri, Nov 23, 2007 at 12:14:43AM +0100, Stefan Reinauer wrote:
- Stefan Reinauer stepan@coresystems.de [071123 00:04]:
- Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net [071122 21:44]:
The introduction of the _SHARED macros had one flaw: If multiple files had _SHARED defined during compilation, each of them would contain an assignment of stage0_printk to *printk. During linking, this caused errors as multiple definitions of printk existed. Make sure _SHARED alone gives you only the printk prototype, and iff _MAINOBJECT is defined as well, include the assignment.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
I like it, but I suggest to simplify the code further.
Uwe was faster. So here's the diff without Carl-Daniel's patch
it gets rid of the per-file rules for initram code completely.
Very nice!
Patch is Signed-off-by: Stefan Reinauer stepan@coresystems.de
Acked-by: Uwe Hermann uwe@hermann-uwe.de
I think we should go even further and specify the INITRAM_SOURCE instead of INITRAM_OBJ because those are the files we care about. (And it will make proper dependencies easier at some point)
Yeah, sounds good.
+# ram initialization code can not be linked at a specific address,
ram -> RAM
Uwe.