This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: section anchors and weak hidden symbols
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: Nathan Sidwell <nathan at acm dot org>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 May 2013 16:32:56 +0200
- Subject: Re: section anchors and weak hidden symbols
- References: <518A3D8E dot 5020800 at acm dot org>
Nathan Sidwell <nathan@acm.org> writes:
> This patch fixes a problem with section anchors. Found on powerpc, but
> also appears on MIPS and ARM targets.
>
> Section anchors can only be used for definitions known to bind in the
> current object file. The default predicate uses the bind_local_p hook to
> determine this. Unfortunately that hook determines whether the decl's
> binding is determined at static link time (i.e. within the dynamic object
> this object is linked). That's very nearly the same, except for symbols
> that have a weak hidden definition in this object file. For such symbols,
> binds_local_p returns true, because the binding must be within the dynamic
> object. But we shouldn't use a section anchor as a definition in a
> different object file could win at static link time. (I'm not 100% sure
> there aren't other cases where module-binding and object-binding differ for
> a definition.)
>
> It surprised me that binds_local_p has the semantics it does -- perhaps its
> meaning has changed, or it is simply poorly named. I would have thought
> binds_module_p would be a better name.
>
> Anyway, rather than go on a renaming exercise, I chose to adjust
> default_use_anchors_for_symbol_p to reject any weak symbol.
>
> tested on powerpc-linux-gnu, ok?
The new gcc.dg/visibility-21.c testcase fails on i386-pc-solaris2.11 and
x86_64-unknown-linux-gnu:
FAIL: gcc.dg/visibility-21.c (test for excess errors)
Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/visibility-21.c:1:0: warning: this target does not support '-fsection-anchors' [-fsection-anchors]
Fixed as follows, tested with the appropriate runtest invokation on both
targets where the test becomes UNSUPPORTED, installed on mainline.
Rainer
2013-05-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/visibility-21.c: Require section_anchors.
# HG changeset patch
# Parent e3635f5f20529d75a74064c8282ce002932dde78
Require section_anchors in gcc.dg/visibility-21.c
diff --git a/gcc/testsuite/gcc.dg/visibility-21.c b/gcc/testsuite/gcc.dg/visibility-21.c
--- a/gcc/testsuite/gcc.dg/visibility-21.c
+++ b/gcc/testsuite/gcc.dg/visibility-21.c
@@ -3,6 +3,7 @@
/* { dg-options "-O2 -fsection-anchors" } */
/* { dg-require-visibility "" } */
/* { dg-require-weak "" } */
+/* { dg-require-effective-target section_anchors } */
/* { dg-final { scan-assembler-not "ANCHOR" } } */
int __attribute__((weak, visibility("hidden"))) weak_hidden[3];
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University