Commit ad117173 by Jim Wilson Committed by Jim Wilson

RISC-V: Fix weak symbols with medany and explicit relocs.

	gcc/
	* config/riscv/riscv.c (riscv_split_symbol): Mark auipc label as weak
	when target symbol is weak.

	gcc/testsuite/
	* gcc.target/riscv/weak-1.c: New.

From-SVN: r264586
parent c7813484
2018-09-25 Jim Wilson <jimw@sifive.com>
* config/riscv/riscv.c (riscv_split_symbol): Mark auipc label as weak
when target symbol is weak.
2018-09-25 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR c/87387
......
......@@ -1103,6 +1103,11 @@ riscv_split_symbol (rtx temp, rtx addr, machine_mode mode, rtx *low_out)
label = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
SYMBOL_REF_FLAGS (label) |= SYMBOL_FLAG_LOCAL;
/* ??? Ugly hack to make weak symbols work. May need to change the
RTL for the auipc and/or low patterns to get a better fix for
this. */
if (! nonzero_address_p (addr))
SYMBOL_REF_WEAK (label) = 1;
if (temp == NULL)
temp = gen_reg_rtx (Pmode);
......
2018-09-25 Jim Wilson <jimw@sifive.com>
* gcc.target/riscv/weak-1.c: New.
2018-09-25 Jeff Law <law@redhat.com>
* gcc.dg/warn-stpcpy-no-nul.c: Drop unnecessary xfails.
......
/* { dg-do compile } */
/* { dg-options "-mcmodel=medany -mexplicit-relocs -O" } */
/* Verify that the branch doesn't get optimized away. */
extern int weak_func(void) __attribute__ ((weak));
int
sub (void)
{
if (weak_func)
return weak_func ();
return 0;
}
/* { dg-final { scan-assembler "b\(ne|eq\)" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment