[PATCH] D21292: [mips] Correct ELF format for N32.

Hongyan Xia via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 02:04:02 PDT 2017


Jerryxia32 added a comment.

> How do you create the n32 object file and run LLD? I would like to reproduce the crash.

Can be reproduced quite easily:

  clang -target mips64 -mcpu=mips4 -mabi=n32 -fPIC -mabicalls -integrated-as -c test.c -o test.o
  clang -target mips64 -mcpu=mips4 -mabi=n32 -fPIC -mabicalls -integrated-as -c test2.c -o test2.o
  ld.lld test.o test2.o -o test
  ld.lld: error: test.c:(function main): relocation R_MIPS_GPREL16 out of range

The disassembly shows GPREL16 relocations inserted in the function prologues which I think caused the problem.
Reduced test case files below.

  test.c:
  
  extern void foo();
  
  int
  main() {
      foo();
      return 0;
  }
  
  test2.c:
  
  void
  foo() {
      volatile int i;
      i += 3;
  }


https://reviews.llvm.org/D21292





More information about the llvm-commits mailing list