Commit 15f6e0da by Ramana Radhakrishnan Committed by Ramana Radhakrishnan

[AArch64] Fix PR target/63874

     In this PR we have a situation where we aren't really detecting
weak references vs weak definitions. If one has a weak definition that
binds locally there's no reason not to put out PC relative
relocations.

However if you have a genuine weak reference that is known not to bind
locally it makes very little sense to put out an entry into the
literal pool which doesn't always work with DSOs and shared objects.

Tested aarch64-none-linux-gnu bootstrap and regression test with no
regressions

2016-07-04  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

	PR target/63874
	* config/aarch64/aarch64.c (aarch64_classify_symbol): Fix
	typo in comment.  Only force to memory if it is a weak
	external reference.

2016-07-04  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

	PR target/63874
	* gcc.target/aarch64/pr63874.c: New test.

From-SVN: r237957
parent c61465bd
2016-07-04 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
PR target/63874
* config/aarch64/aarch64.c (aarch64_classify_symbol): Fix
typo in comment. Only force to memory if it is a weak
external reference.
2016-07-04 Matthew Wahab <matthew.wahab@arm.com> 2016-07-04 Matthew Wahab <matthew.wahab@arm.com>
Jiong Wang <jiong.wang@arm.com> Jiong Wang <jiong.wang@arm.com>
......
...@@ -9423,15 +9423,18 @@ aarch64_classify_symbol (rtx x, rtx offset) ...@@ -9423,15 +9423,18 @@ aarch64_classify_symbol (rtx x, rtx offset)
switch (aarch64_cmodel) switch (aarch64_cmodel)
{ {
case AARCH64_CMODEL_TINY: case AARCH64_CMODEL_TINY:
/* When we retreive symbol + offset address, we have to make sure /* When we retrieve symbol + offset address, we have to make sure
the offset does not cause overflow of the final address. But the offset does not cause overflow of the final address. But
we have no way of knowing the address of symbol at compile time we have no way of knowing the address of symbol at compile time
so we can't accurately say if the distance between the PC and so we can't accurately say if the distance between the PC and
symbol + offset is outside the addressible range of +/-1M in the symbol + offset is outside the addressible range of +/-1M in the
TINY code model. So we rely on images not being greater than TINY code model. So we rely on images not being greater than
1M and cap the offset at 1M and anything beyond 1M will have to 1M and cap the offset at 1M and anything beyond 1M will have to
be loaded using an alternative mechanism. */ be loaded using an alternative mechanism. Furthermore if the
if (SYMBOL_REF_WEAK (x) symbol is a weak reference to something that isn't known to
resolve to a symbol in this module, then force to memory. */
if ((SYMBOL_REF_WEAK (x)
&& !aarch64_symbol_binds_local_p (x))
|| INTVAL (offset) < -1048575 || INTVAL (offset) > 1048575) || INTVAL (offset) < -1048575 || INTVAL (offset) > 1048575)
return SYMBOL_FORCE_TO_MEM; return SYMBOL_FORCE_TO_MEM;
return SYMBOL_TINY_ABSOLUTE; return SYMBOL_TINY_ABSOLUTE;
...@@ -9439,7 +9442,8 @@ aarch64_classify_symbol (rtx x, rtx offset) ...@@ -9439,7 +9442,8 @@ aarch64_classify_symbol (rtx x, rtx offset)
case AARCH64_CMODEL_SMALL: case AARCH64_CMODEL_SMALL:
/* Same reasoning as the tiny code model, but the offset cap here is /* Same reasoning as the tiny code model, but the offset cap here is
4G. */ 4G. */
if (SYMBOL_REF_WEAK (x) if ((SYMBOL_REF_WEAK (x)
&& !aarch64_symbol_binds_local_p (x))
|| !IN_RANGE (INTVAL (offset), HOST_WIDE_INT_C (-4294967263), || !IN_RANGE (INTVAL (offset), HOST_WIDE_INT_C (-4294967263),
HOST_WIDE_INT_C (4294967264))) HOST_WIDE_INT_C (4294967264)))
return SYMBOL_FORCE_TO_MEM; return SYMBOL_FORCE_TO_MEM;
......
2016-07-04 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
PR target/63874
* gcc.target/aarch64/pr63874.c: New test.
2016-07-04 Jan Beulich <jbeulich@suse.com> 2016-07-04 Jan Beulich <jbeulich@suse.com>
* g++.dg/header.c: New. * g++.dg/header.c: New.
......
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* { dg-skip-if "Not applicable for mcmodel=large" { aarch64*-*-* } { "-mcmodel=large" } { "" } } */
extern void __attribute__((weak)) foo_weakref (void);
void __attribute__((weak, noinline)) bar (void)
{
return;
}
void (*f) (void);
void (*g) (void);
int
main (void)
{
f = &foo_weakref;
g = &bar;
return 0;
}
/* { dg-final { scan-assembler-not "adr*foo_weakref" } } */
/* { dg-final { scan-assembler-not "\\.(word|xword)\tbar" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment