From: Daniel Kiper <dkiper@net-space.pl>
To: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Cc: The development of GRUB 2 <grub-devel@gnu.org>,
Ard Biesheuvel <ardb@kernel.org>,
Glenn Washburn <development@efficientek.com>,
Dave Pickens <drummer@pobox.com>
Subject: Re: [PATCH] STACK_PROTECTOR: Support symbols emitted by windows compiler
Date: Fri, 5 Apr 2024 13:23:29 +0200 [thread overview]
Message-ID: <20240405112329.ffzjimcspht7fgr6@tomti.i.net-space.pl> (raw)
In-Reply-To: <CAEaD8JNWh_5ByoA0EoJiTceztmw13yvm-ES737g3wEqz3ScpFQ@mail.gmail.com>
On Fri, Apr 05, 2024 at 12:39:41AM +0300, Vladimir 'phcoder' Serbinenko wrote:
> I didn't know about using weakref for this but I'm fine with the approach. Just
> one thing: can we condition it on HAVE_ASM_USCORE test instead of platform?
Interestingly it is set to 0 for x86_64 MinGW and other Linux builds
and set to 1 for i686 MinGW. And it looks only x86_64 MinGW builds are
broken. So, the HAVE_ASM_USCORE itself would not work for us. Instead
I would do s/_WIN32/_WIN64/ in the ifdefery below to improve detection.
AFAICT the "#if defined(_WIN32) && !defined(__CYGWIN__)" is common
mechanism to detect MinGW in general.
> Le jeu. 4 avr. 2024, 23:47, Daniel Kiper <dkiper@net-space.pl> a écrit :
> Adding Ard, Glenn and Dave...
>
> First of all, sorry for late reply but I was busy with other stuff...
>
> On Fri, Mar 15, 2024 at 09:43:22PM +0300, Vladimir 'phcoder'
> Serbinenko wrote:
> > stack protector needs symbols with just one underscore in C
> > name unlike unix variant that needs double underscore.
> > Supply both symbols for simplicity
> >
> > Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
>
> I do not like your solution because it adds unneeded code/symbols to
> some EFI builds. I come up with two other solutions.
>
> First, let's define an alias when using MinGW build environment:
>
> diff --git a/include/grub/stack_protector.h b/include/grub/
> stack_protector.h
> index c88dc00b5..8d99fd50e 100644
> --- a/include/grub/stack_protector.h
> +++ b/include/grub/stack_protector.h
> @@ -25,6 +25,10 @@
> #ifdef GRUB_STACK_PROTECTOR
> extern grub_addr_t EXPORT_VAR (__stack_chk_guard);
> extern void __attribute__ ((noreturn)) EXPORT_FUNC (__stack_chk_fail) (void);
> +#if defined(_WIN32) && !defined(__CYGWIN__)
> +static grub_addr_t __attribute__ ((weakref("__stack_chk_guard"))) EXPORT_VAR (_stack_chk_guard);
> +static void __attribute__ ((noreturn, weakref("__stack_chk_fail"))) EXPORT_FUNC (_stack_chk_fail) (void);
> +#endif
> #endif
>
> #endif /* GRUB_STACK_PROTECTOR_H */
Daniel
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
prev parent reply other threads:[~2024-04-05 11:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-15 18:43 [PATCH] STACK_PROTECTOR: Support symbols emitted by windows compiler Vladimir 'phcoder' Serbinenko
2024-04-03 21:27 ` Glenn Washburn
2024-04-04 20:50 ` Daniel Kiper
2024-04-04 20:47 ` Daniel Kiper
2024-04-04 21:39 ` Vladimir 'phcoder' Serbinenko
2024-04-05 11:23 ` Daniel Kiper [this message]
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=20240405112329.ffzjimcspht7fgr6@tomti.i.net-space.pl \
--to=dkiper@net-space.pl \
--cc=ardb@kernel.org \
--cc=development@efficientek.com \
--cc=drummer@pobox.com \
--cc=grub-devel@gnu.org \
--cc=phcoder@gmail.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).