[PATCH] D28564: [ELF] - Explicitly list supported relocations for x64 target.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 08:02:35 PST 2017


LGTM.

Thanks!

George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar created this revision.
> grimar added reviewers: ruiu, rafael.
> grimar added subscribers: llvm-commits, grimar, evgeny777.
>
> The same we did for x86 earlier.
>
>
> https://reviews.llvm.org/D28564
>
> Files:
>   ELF/Target.cpp
>   test/ELF/invalid/invalid-relocation-x64.s
>
>
> Index: test/ELF/invalid/invalid-relocation-x64.s
> ===================================================================
> --- test/ELF/invalid/invalid-relocation-x64.s
> +++ test/ELF/invalid/invalid-relocation-x64.s
> @@ -26,5 +26,5 @@
>          Type:            R_X86_64_NONE
>  
>  # RUN: not ld.lld %p/Inputs/invalid-relocation-x64.elf -o %t2 2>&1 | FileCheck %s
> -# CHECK: unrecognized reloc 152
> -# CHECK: unrecognized reloc 153
> +# CHECK: do not know how to handle relocation 'Unknown' (152)
> +# CHECK: do not know how to handle relocation 'Unknown' (153)
> Index: ELF/Target.cpp
> ===================================================================
> --- ELF/Target.cpp
> +++ ELF/Target.cpp
> @@ -631,7 +631,11 @@
>  RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type,
>                                             const SymbolBody &S) const {
>    switch (Type) {
> -  default:
> +  case R_X86_64_32:
> +  case R_X86_64_32S:
> +  case R_X86_64_64:
> +  case R_X86_64_DTPOFF32:
> +  case R_X86_64_DTPOFF64:
>      return R_ABS;
>    case R_X86_64_TPOFF32:
>      return R_TLS;
> @@ -657,6 +661,10 @@
>      return R_GOT_PC;
>    case R_X86_64_NONE:
>      return R_HINT;
> +  default:
> +    error("do not know how to handle relocation '" + toString(Type) + "' (" +
> +          Twine(Type) + ")");
> +    return R_HINT;
>    }
>  }
>  
> @@ -878,7 +886,7 @@
>      write64le(Loc, Val);
>      break;
>    default:
> -    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
> +    llvm_unreachable("unexpected relocation");
>    }
>  }
>  
>
>
> Index: test/ELF/invalid/invalid-relocation-x64.s
> ===================================================================
> --- test/ELF/invalid/invalid-relocation-x64.s
> +++ test/ELF/invalid/invalid-relocation-x64.s
> @@ -26,5 +26,5 @@
>          Type:            R_X86_64_NONE
>  
>  # RUN: not ld.lld %p/Inputs/invalid-relocation-x64.elf -o %t2 2>&1 | FileCheck %s
> -# CHECK: unrecognized reloc 152
> -# CHECK: unrecognized reloc 153
> +# CHECK: do not know how to handle relocation 'Unknown' (152)
> +# CHECK: do not know how to handle relocation 'Unknown' (153)
> Index: ELF/Target.cpp
> ===================================================================
> --- ELF/Target.cpp
> +++ ELF/Target.cpp
> @@ -631,7 +631,11 @@
>  RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type,
>                                             const SymbolBody &S) const {
>    switch (Type) {
> -  default:
> +  case R_X86_64_32:
> +  case R_X86_64_32S:
> +  case R_X86_64_64:
> +  case R_X86_64_DTPOFF32:
> +  case R_X86_64_DTPOFF64:
>      return R_ABS;
>    case R_X86_64_TPOFF32:
>      return R_TLS;
> @@ -657,6 +661,10 @@
>      return R_GOT_PC;
>    case R_X86_64_NONE:
>      return R_HINT;
> +  default:
> +    error("do not know how to handle relocation '" + toString(Type) + "' (" +
> +          Twine(Type) + ")");
> +    return R_HINT;
>    }
>  }
>  
> @@ -878,7 +886,7 @@
>      write64le(Loc, Val);
>      break;
>    default:
> -    error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
> +    llvm_unreachable("unexpected relocation");
>    }
>  }
>  


More information about the llvm-commits mailing list