From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH] build/xen: fix symbol generation with LLVM LD
Date: Fri, 6 May 2022 17:35:24 +0200 [thread overview]
Message-ID: <YnVAPMZ0+dd9jLF9@Air-de-Roger> (raw)
In-Reply-To: <YnUjICUinDIiNJ3p@Air-de-Roger>
On Fri, May 06, 2022 at 03:31:12PM +0200, Roger Pau Monné wrote:
> On Fri, May 06, 2022 at 02:56:56PM +0200, Jan Beulich wrote:
> > On 05.05.2022 16:21, Roger Pau Monne wrote:
> > > --- a/xen/include/xen/compiler.h
> > > +++ b/xen/include/xen/compiler.h
> > > @@ -125,10 +125,11 @@
> > > #define __must_be_array(a) \
> > > BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
> > >
> > > -#ifdef CONFIG_CC_HAS_VISIBILITY_ATTRIBUTE
> > > -/* Results in more efficient PIC code (no indirections through GOT or PLT). */
> > > -#pragma GCC visibility push(hidden)
> > > -#endif
> > > +/*
> > > + * Results in more efficient PIC code (no indirections through GOT or PLT)
> > > + * and is also required by some of the assembly constructs.
> > > + */
> > > +#pragma GCC visibility push(protected)
> > >
> > > /* Make the optimizer believe the variable can be manipulated arbitrarily. */
> > > #define OPTIMIZER_HIDE_VAR(var) __asm__ ( "" : "+g" (var) )
> >
> > This has failed my pre-push build test, with massive amounts of errors
> > about asm() constraints in the alternative call infrastructure. This
> > was with gcc 11.3.0.
>
> Hm, great. I guess I will have to use protected with clang and hidden
> with gcc then, for lack of a better solution.
>
> I'm slightly confused as to why my godbolt example:
>
> https://godbolt.org/z/chTnMWxeP
>
> Seems to work with gcc 11 then. I will have to investigate a bit I
> think.
So it seems the problem is explicitly with constructs like:
void (*foo)(void);
void test(void)
{
asm volatile (".long [addr]" :: [addr] "i" (&(foo)));
}
See:
https://godbolt.org/z/TYqeGdWsn
AFAICT gcc will consider the function pointer foo to go through the
GOT/PLT redirection table, while clang will not. I think gcc behavior
is correct because in theory foo could be set from a different module?
protect only guarantees that references to local functions cannot be
overwritten, but not external ones.
I don't really see a good way to fix this, rather that setting
different visibilities based on the compiler. clang would use
protected and gcc would use hidden. I think it's unlikely to have a
toolstack setup to use gcc as the compiler and LLVM LD as the
linker, which would be the problematic configuration, and even in that
case it's kind of a cosmetic issue with symbol resolution, binary
output from the linker would still be correct.
Let me know if that seems acceptable.
Thanks, Roger.
next prev parent reply other threads:[~2022-05-06 15:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 14:21 [PATCH] build/xen: fix symbol generation with LLVM LD Roger Pau Monne
2022-05-06 10:25 ` Jan Beulich
2022-05-06 12:56 ` Jan Beulich
2022-05-06 13:31 ` Roger Pau Monné
2022-05-06 15:35 ` Roger Pau Monné [this message]
2022-05-08 8:34 ` Jan Beulich
2022-05-16 8:01 ` Roger Pau Monné
2022-05-17 12:26 ` Jan Beulich
2022-07-06 7:30 ` Henry Wang
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=YnVAPMZ0+dd9jLF9@Air-de-Roger \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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 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.