[PATCH] D34138: [LLD][ELF] make default for get{ARM, AArch64}UndefinedRelativeWeakVA unreachable

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 09:57:01 PDT 2017


Peter Smith via Phabricator <reviews at reviews.llvm.org> writes:
>  static uint32_t getARMUndefinedRelativeWeakVA(uint32_t Type, uint32_t A,
>                                                uint32_t P) {
>    switch (Type) {
> +  // Unresolved branch relocations to weak references resolve to next
> +  // instruction.
>    case R_ARM_THM_JUMP11:
>      return P + 2 + A;
>    case R_ARM_CALL:
> @@ -415,21 +417,38 @@
>    case R_ARM_THM_CALL:
>      // We don't want an interworking BLX to ARM
>      return P + 5 + A;
> -  default:
> +  // Unresolved relative relocations to weak references resolve to the place
> +  // R_ARM_TARGET2 which can be resolved relatively is not present as it never
> +  // targets a weak-reference.
> +  case R_ARM_MOVW_PREL_NC:
> +  case R_ARM_MOVT_PREL:
> +  case R_ARM_REL32:
> +  case R_ARM_THM_MOVW_PREL_NC:
> +  case R_ARM_THM_MOVT_PREL:
>      return P + A;
> +  default:
> +    llvm_unreachable("ARM pc-relative relocation expected\n");
>    }

I think you have to move the llvm_unreachable after the switch to avoid
a warning with gcc:

--------------------------------------------------------------
  case R_ARM_THM_MOVT_PREL:
    return P + A;
  }
  llvm_unreachable("ARM pc-relative relocation expected\n");
}
--------------------------------------------------------------

LGTM with that.

Cheers,
Rafeal


More information about the llvm-commits mailing list