Current LLVM LD implementation will turn global hidden symbols in
object files into local ones when generating the .symtab of the Xen
binary image.

This is different from GNU ld implementation, that will only do the
conversion (or remove the symbols) when generation .dynsym but not
.symtab.  Such conversion breaks the processing of symbols done by
tools/symbols.

Use protected symbol visibility instead of hidden, as that preserves
the symbol binding while not generating GOT or PLT indirections that
are not compatible with some of the inline assembly constructs
currently used.

While there also make the visibility setting compiler support
non-optional: compilers not supporting it won't be able to build Xen
anyway, and will just throw a compiler error sooner rather than later
during the build.

Signed-off-by: Roger Pau Monné <roger....@citrix.com>
---
 xen/Kconfig                | 4 ----
 xen/include/xen/compiler.h | 9 +++++----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/xen/Kconfig b/xen/Kconfig
index 134e6e68ad..a9182fb13d 100644
--- a/xen/Kconfig
+++ b/xen/Kconfig
@@ -29,10 +29,6 @@ config LD_IS_GNU
 config LD_IS_LLVM
        def_bool $(success,$(LD) --version | head -n 1 | grep -q "^LLD")
 
-# -fvisibility=hidden reduces -fpic cost, if it's available
-config CC_HAS_VISIBILITY_ATTRIBUTE
-       def_bool $(cc-option,-fvisibility=hidden)
-
 # Use -f{function,data}-sections compiler parameters
 config CC_SPLIT_SECTIONS
        bool
diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h
index 933aec09a9..c144b17217 100644
--- 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) )
-- 
2.36.0


Reply via email to