Patchwork section anchors and weak hidden symbols

login
register
mail settings
Submitter Rainer Orth
Date May 16, 2013, 2:32 p.m.
Message ID <yddr4h7xaef.fsf@lokon.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/244345/
State New
Headers show

Comments

Rainer Orth - May 16, 2013, 2:32 p.m.
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.
Nathan Sidwell - May 17, 2013, 6:55 a.m.
On 05/16/13 15:32, Rainer Orth wrote:

> 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.

thanks!

Patch

# 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];