+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>
Jiong Wang <jiong.wang@arm.com>
switch (aarch64_cmodel)
{
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
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
symbol + offset is outside the addressible range of +/-1M in the
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
- be loaded using an alternative mechanism. */
- if (SYMBOL_REF_WEAK (x)
+ be loaded using an alternative mechanism. Furthermore if the
+ 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)
return SYMBOL_FORCE_TO_MEM;
return SYMBOL_TINY_ABSOLUTE;
case AARCH64_CMODEL_SMALL:
/* Same reasoning as the tiny code model, but the offset cap here is
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),
HOST_WIDE_INT_C (4294967264)))
return SYMBOL_FORCE_TO_MEM;
--- /dev/null
+/* { 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" } } */