Grub Development Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Franke <Christian.Franke@t-online.de>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: NEED_REGISTER_FRAME_INFO can be replaced by -static-libgcc
Date: Wed, 14 Apr 2010 12:35:32 +0200	[thread overview]
Message-ID: <4BC59A74.5080900@t-online.de> (raw)
In-Reply-To: <4BC4C4FA.2050005@gmail.com>

[-- 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@


  reply	other threads:[~2010-04-14 10:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=4BC59A74.5080900@t-online.de \
    --to=christian.franke@t-online.de \
    --cc=grub-devel@gnu.org \
    /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