On Fri, Nov 14, 2014 at 12:12 AM, Tejas Belagod <tejas.bela...@arm.com> wrote:
>
> Hi,
>
> Following the discussion here
> https://gcc.gnu.org/ml/gcc-patches/2014-09/msg02237.html, this has been
> tracked down to a range-checking bug with symbol + offset style addressing
> with adrp where we allowed any arbitrary offset and this would cause
> truncation of final addresses when relocations were being resolved by ld.
> When we retreive 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 alternate mechanism.
> Similarly for the SMALL code model the offset has been capped at 4G.
>
> The cap value for the offset in each code model is open to debate.
>
> All testing done with Alan's workaround
> patch(https://gcc.gnu.org/ml/gcc-patches/2014-09/msg01509.html) reversed.
>
> bootstrapped aarch64-linux.
>
> OK for trunk?

This looks like a better fix than I would have came up with.
Since you are touching this area you might want to look into this issue:
I notice SYMBOL_REF_WEAK (x) is true for references(decls) which are
comdat's which are declared in the translation unit.  So force them to
memory when really we know they are declared and don't have a value of
zero so they will fit in the medium code model.  This happens with
vtables and we lose some performance because of this.

Thanks,
Andrew Pinski


>
> Thanks,
> Tejas.
>
> 2014-11-14  Tejas Belagod  <tejas.bela...@arm.com>
>
> gcc/
>         * config/aarch64/aarch64-protos.h (aarch64_classify_symbol):
>         Fixup prototype.
>         * config/aarch64/aarch64.c (aarch64_expand_mov_immediate,
>         aarch64_cannot_force_const_mem, aarch64_classify_address,
>         aarch64_classify_symbolic_expression): Fixup call to
>         aarch64_classify_symbol.
>         (aarch64_classify_symbol): Add range-checking for
>         symbol + offset addressing for tiny and small models.
>
> testsuite/
>         * gcc.target/aarch64/symbol-range.c: New.
>         * gcc.target/aarch64/symbol-range-tiny.c: New.

Reply via email to