diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-10-10 15:43:00 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-10-10 15:43:58 -0700 |
commit | e05cc858aa5a6ed1ae0fec885a83090f81f355fe (patch) | |
tree | 50b93a74af26195701d468735903f7dae1ea20b9 | |
parent | 0c7ef246246f8abd971ccf7d1b33073ae5e9e67e (diff) | |
download | riscv-gnu-toolchain-e05cc858aa5a6ed1ae0fec885a83090f81f355fe.zip riscv-gnu-toolchain-e05cc858aa5a6ed1ae0fec885a83090f81f355fe.tar.gz riscv-gnu-toolchain-e05cc858aa5a6ed1ae0fec885a83090f81f355fe.tar.bz2 |
binutils: relax LA macro to C.LUI when appropriate
-rw-r--r-- | binutils/gas/config/tc-riscv.c | 10 | ||||
-rw-r--r-- | glibc/sysdeps/riscv/start.S | 3 |
2 files changed, 10 insertions, 3 deletions
diff --git a/binutils/gas/config/tc-riscv.c b/binutils/gas/config/tc-riscv.c index 2d77871..d7e5bb6 100644 --- a/binutils/gas/config/tc-riscv.c +++ b/binutils/gas/config/tc-riscv.c @@ -937,12 +937,18 @@ macro (struct riscv_cl_insn *ip, expressionS *imm_expr, if (imm_expr->X_op == O_constant) load_const (rd, imm_expr); - else if (riscv_opts.pic && mask == M_LA) /* Global PIC symbol */ + else if (riscv_opts.pic && mask == M_LA) /* Global symbol in PIC */ pcrel_load (rd, rd, imm_expr, LOAD_ADDRESS_INSN, BFD_RELOC_RISCV_GOT_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); - else /* Local PIC symbol, or any non-PIC symbol */ + else if (riscv_opts.pic) /* Local symbol in PIC */ pcrel_load (rd, rd, imm_expr, "addi", BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); + else /* Any symbol in non-PIC */ + { + macro_build (imm_expr, "lui", "d,u", rd, BFD_RELOC_RISCV_HI20); + macro_build (imm_expr, "addi", "d,s,j", rd, rd, + BFD_RELOC_RISCV_LO12_I); + } break; case M_LA_TLS_GD: diff --git a/glibc/sysdeps/riscv/start.S b/glibc/sysdeps/riscv/start.S index 8195002..1f64d80 100644 --- a/glibc/sysdeps/riscv/start.S +++ b/glibc/sysdeps/riscv/start.S @@ -45,7 +45,8 @@ __libc_start_main wants this in a5. */ ENTRY(ENTRY_POINT) - lla gp, _gp +1: auipc gp, %pcrel_hi(_gp) + addi gp, gp, %pcrel_lo(1b) move a5, a0 /* rtld_fini */ lla a0, main REG_L a1, 0(sp) /* argc */ |