* NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc
@ 2010-04-13 19:10 Christian Franke
2010-04-13 19:24 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 6+ messages in thread
From: Christian Franke @ 2010-04-13 19:10 UTC (permalink / raw)
To: grub-devel
Hi,
a note regarding this fix:
2010-04-11 Vladimir Serbinenko <...>
Fix cygwin compilation.
* configure.ac: Define NEED_REGISTER_FRAME_INFO.
* include/grub/misc.h (__register_frame_info)
[NEED_REGISTER_FRAME_INFO && !UTIL]: New export.
(__deregister_frame_info) [NEED_REGISTER_FRAME_INFO && !UTIL]:
Likewise.
* kern/misc.c (__register_frame_info)
[NEED_REGISTER_FRAME_INFO && !UTIL]: New empty function.
(__deregister_frame_info) [NEED_REGISTER_FRAME_INFO && !UTIL]:
Likewise.
--- configure.ac 2010-04-11 14:14:51 +0000
+++ configure.ac 2010-04-12 14:58:44 +0000
@@ -376,7 +376,11 @@
# For platforms where ELF is not the default link format.
AC_MSG_CHECKING([for command to convert module to ELF format])
case "${host_os}" in
- cygwin) TARGET_OBJ2ELF='grub-pe2elf' ;;
+ cygwin) TARGET_OBJ2ELF='grub-pe2elf';
+# FIXME: put proper test here
+ AC_DEFINE([NEED_REGISTER_FRAME_INFO], 1,
+ [Define to 1 if GCC generates calls to __register_frame_info()])
+ ;;
*) ;;
The *_frame_info symbols are set undefined to force linkage of the
libgcc_s shared library or dll.
This can be prevented by TARGET_LDFLAGS=-static-libgcc. To build from
grub-1.98 tarball on Cygwin, run configure with this argument.
May also be necessary on other build platforms when -shared-libgcc is
the default. It may be possible simply set -static-libgcc unconditionally.
--
Regards,
Christian Franke
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc
2010-04-13 19:10 NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc Christian Franke
@ 2010-04-13 19:24 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-04-14 10:35 ` Christian Franke
0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-04-13 19:24 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 875 bytes --]
Christian Franke wrote:
> Hi,
>
> a note regarding this fix:
>
>
> The *_frame_info symbols are set undefined to force linkage of the
> libgcc_s shared library or dll.
>
> This can be prevented by TARGET_LDFLAGS=-static-libgcc. To build from
> grub-1.98 tarball on Cygwin, run configure with this argument.
>
> May also be necessary on other build platforms when -shared-libgcc is
> the default. It may be possible simply set -static-libgcc
> unconditionally.
>
We already supply -lgcc --static-libgcc. Do you know why it still had
issues?
And I also doubt usefullness of pulling these functions since reference
to them is purely dummy: no relocation uses it so it will only increase
code size. Another concern is the behviour of these functions in grub
environment if they ever get called.
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc
2010-04-13 19:24 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2010-04-14 10:35 ` Christian Franke
2010-04-17 20:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-04-24 21:19 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 2 replies; 6+ messages in thread
From: Christian Franke @ 2010-04-14 10:35 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 1615 bytes --]
Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> Christian Franke wrote:
>
>
>> The *_frame_info symbols are set undefined to force linkage of the
>> libgcc_s shared library or dll.
>>
>> This can be prevented by TARGET_LDFLAGS=-static-libgcc. To build from
>> grub-1.98 tarball on Cygwin, run configure with this argument.
>>
>> May also be necessary on other build platforms when -shared-libgcc is
>> the default. It may be possible simply set -static-libgcc
>> unconditionally.
>>
>>
> We already supply -lgcc --static-libgcc. Do you know why it still had
> issues?
>
The above is only set when linking the kernel image.
According to 'gcc -dumpspecs' of Cygwin gcc 4.3.4-3, options '-u
___[de]register_frame_info' are always passed to the linker if
-static-libgcc is not specified. This is Cygwin and MinGW specific: In
the exe startup code these symbols are loaded only if present, so the
DLL must be forced to load first.
As a consequence, the symbols are also set undefined when the GRUB
pre-*.o files are generated with 'ld -r'.
The attached patch works for me with the bzr revision preceding the
NEED_REGISTER_FRAME_INFO fix.
> And I also doubt usefullness of pulling these functions since reference
> to them is purely dummy: no relocation uses it so it will only increase
> code size. Another concern is the behviour of these functions in grub
> environment if they ever get called.
>
>
AFAICS from the gcc source, the functions are used in EH stack unwinding
code in libgcc. The compiler itself does not generate calls to these
functions.
--
Regards,
Christian Franke
[-- Attachment #2: grub2-static-libgcc.patch --]
[-- Type: text/x-diff, Size: 671 bytes --]
=== modified file 'Makefile.in'
--- Makefile.in 2010-04-10 23:14:31 +0000
+++ Makefile.in 2010-04-14 08:04:34 +0000
@@ -98,12 +98,12 @@
OBJCONV = @OBJCONV@
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
-Wall -W
-TARGET_LDFLAGS = -nostdlib @TARGET_LDFLAGS@
+TARGET_LDFLAGS = -nostdlib -static-libgcc @TARGET_LDFLAGS@
TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
TARGET_IMG_LDFLAGS = -nostdlib @TARGET_IMG_LDFLAGS@
TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
-kernel_img_LDFLAGS = -static-libgcc -lgcc
+kernel_img_LDFLAGS = -lgcc
EXEEXT = @EXEEXT@
OBJCOPY = @OBJCOPY@
STRIP = @STRIP@
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc
2010-04-14 10:35 ` Christian Franke
@ 2010-04-17 20:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-04-19 15:13 ` Christian Franke
2010-04-24 21:19 ` Vladimir 'φ-coder/phcoder' Serbinenko
1 sibling, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-04-17 20:52 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 2128 bytes --]
Christian Franke wrote:
> Vladimir 'φ-coder/phcoder' Serbinenko wrote:
>> Christian Franke wrote:
>>
>>> The *_frame_info symbols are set undefined to force linkage of the
>>> libgcc_s shared library or dll.
>>>
>>> This can be prevented by TARGET_LDFLAGS=-static-libgcc. To build from
>>> grub-1.98 tarball on Cygwin, run configure with this argument.
>>>
>>> May also be necessary on other build platforms when -shared-libgcc is
>>> the default. It may be possible simply set -static-libgcc
>>> unconditionally.
>>>
>>>
>> We already supply -lgcc --static-libgcc. Do you know why it still had
>> issues?
>>
>
> The above is only set when linking the kernel image.
>
> According to 'gcc -dumpspecs' of Cygwin gcc 4.3.4-3, options '-u
> ___[de]register_frame_info' are always passed to the linker if
> -static-libgcc is not specified. This is Cygwin and MinGW specific: In
> the exe startup code these symbols are loaded only if present, so the
> DLL must be forced to load first.
>
> As a consequence, the symbols are also set undefined when the GRUB
> pre-*.o files are generated with 'ld -r'.
>
> The attached patch works for me with the bzr revision preceding the
> NEED_REGISTER_FRAME_INFO fix.
>
Doesn't it risk linking e.g. __bswapsi2 into every module which uses it
during partial link? It would increase module size on RISC
>
>> And I also doubt usefullness of pulling these functions since reference
>> to them is purely dummy: no relocation uses it so it will only increase
>> code size. Another concern is the behviour of these functions in grub
>> environment if they ever get called.
>>
>>
>
> AFAICS from the gcc source, the functions are used in EH stack
> unwinding code in libgcc. The compiler itself does not generate calls
> to these functions.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc
2010-04-17 20:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2010-04-19 15:13 ` Christian Franke
0 siblings, 0 replies; 6+ messages in thread
From: Christian Franke @ 2010-04-19 15:13 UTC (permalink / raw)
To: The development of GNU GRUB
Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> Christian Franke wrote:
>
>>
>> According to 'gcc -dumpspecs' of Cygwin gcc 4.3.4-3, options '-u
>> ___[de]register_frame_info' are always passed to the linker if
>> -static-libgcc is not specified. This is Cygwin and MinGW specific: In
>> the exe startup code these symbols are loaded only if present, so the
>> DLL must be forced to load first.
>>
>> As a consequence, the symbols are also set undefined when the GRUB
>> pre-*.o files are generated with 'ld -r'.
>>
>> The attached patch works for me with the bzr revision preceding the
>> NEED_REGISTER_FRAME_INFO fix.
>>
>>
> Doesn't it risk linking e.g. __bswapsi2 into every module which uses it
> during partial link? It would increase module size on RISC
>
Partial linking with '-Wl,-r' does never pull any code from libraries.
Specifying '-lgcc' has no effect in this case.
Cannot test this on RISC, it is at least true on i686-linux, -freebsd
and -cygwin.
--
Regards,
Christian Franke
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc
2010-04-14 10:35 ` Christian Franke
2010-04-17 20:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2010-04-24 21:19 ` Vladimir 'φ-coder/phcoder' Serbinenko
1 sibling, 0 replies; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-04-24 21:19 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 2005 bytes --]
Applied.
Christian Franke wrote:
> Vladimir 'φ-coder/phcoder' Serbinenko wrote:
>> Christian Franke wrote:
>>
>>> The *_frame_info symbols are set undefined to force linkage of the
>>> libgcc_s shared library or dll.
>>>
>>> This can be prevented by TARGET_LDFLAGS=-static-libgcc. To build from
>>> grub-1.98 tarball on Cygwin, run configure with this argument.
>>>
>>> May also be necessary on other build platforms when -shared-libgcc is
>>> the default. It may be possible simply set -static-libgcc
>>> unconditionally.
>>>
>>>
>> We already supply -lgcc --static-libgcc. Do you know why it still had
>> issues?
>>
>
> The above is only set when linking the kernel image.
>
> According to 'gcc -dumpspecs' of Cygwin gcc 4.3.4-3, options '-u
> ___[de]register_frame_info' are always passed to the linker if
> -static-libgcc is not specified. This is Cygwin and MinGW specific: In
> the exe startup code these symbols are loaded only if present, so the
> DLL must be forced to load first.
>
> As a consequence, the symbols are also set undefined when the GRUB
> pre-*.o files are generated with 'ld -r'.
>
> The attached patch works for me with the bzr revision preceding the
> NEED_REGISTER_FRAME_INFO fix.
>
>
>> And I also doubt usefullness of pulling these functions since reference
>> to them is purely dummy: no relocation uses it so it will only increase
>> code size. Another concern is the behviour of these functions in grub
>> environment if they ever get called.
>>
>>
>
> AFAICS from the gcc source, the functions are used in EH stack
> unwinding code in libgcc. The compiler itself does not generate calls
> to these functions.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-04-24 21:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-13 19:10 NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc Christian Franke
2010-04-13 19:24 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-04-14 10:35 ` Christian Franke
2010-04-17 20:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-04-19 15:13 ` Christian Franke
2010-04-24 21:19 ` Vladimir 'φ-coder/phcoder' Serbinenko
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.