From 4107ae2218c9a74fce40d50cb68a7a5ab0bf06e5 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 27 Feb 2013 21:39:20 +0000 Subject: [PATCH] * reloc.c (BFD_RELOC_RL78_CODE): Add. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. * elf32-rl78.c (rl78_elf_relocate_section): Handle weak code references in compuated relocs. * config/tc-rl78.c (reloc_function): Add %code -> BFD_RELOC_RL78_CODE. (rl78_op): Handle %code(). (rl78_cons_fix_new): Likewise, but ignore for 20-bit operands. (tc_gen_reloc): Likwise; convert to a computed reloc. (md_apply_fix): Likewise. --- bfd/ChangeLog | 8 ++++++++ bfd/bfd-in2.h | 1 + bfd/elf32-rl78.c | 2 ++ bfd/libbfd.h | 1 + bfd/reloc.c | 2 ++ gas/ChangeLog | 8 ++++++++ gas/config/tc-rl78.c | 14 ++++++++++++++ 7 files changed, 36 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 50f742dc5c..27746f20f2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2013-02-27 DJ Delorie + + * reloc.c (BFD_RELOC_RL78_CODE): Add. + * libbfd.h: Regenerate. + * bfd-in2.h: Regenerate. + * elf32-rl78.c (rl78_elf_relocate_section): Handle weak code + references in compuated relocs. + 2013-02-26 Anthony Green * config.bfd: Extend moxie-rtems target triplet name support. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 6dfd17fa9b..524e97e78b 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -4239,6 +4239,7 @@ in .byte hlo8(symbol) */ BFD_RELOC_RL78_HI16, BFD_RELOC_RL78_HI8, BFD_RELOC_RL78_LO16, + BFD_RELOC_RL78_CODE, /* Renesas RX Relocations. */ BFD_RELOC_RX_NEG8, diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c index 3a46c6bd09..ea9a0760d5 100644 --- a/bfd/elf32-rl78.c +++ b/bfd/elf32-rl78.c @@ -778,6 +778,8 @@ rl78_elf_relocate_section + sec->output_section->vma + sec->output_offset + rel->r_addend); + else if (h->root.type == bfd_link_hash_undefweak) + RL78_STACK_PUSH (0); else _bfd_error_handler (_("Warning: RL78_SYM reloc with an unknown symbol")); } diff --git a/bfd/libbfd.h b/bfd/libbfd.h index bcd76a0f2a..857d1ea3b7 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1970,6 +1970,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_RL78_HI16", "BFD_RELOC_RL78_HI8", "BFD_RELOC_RL78_LO16", + "BFD_RELOC_RL78_CODE", "BFD_RELOC_RX_NEG8", "BFD_RELOC_RX_NEG16", "BFD_RELOC_RX_NEG24", diff --git a/bfd/reloc.c b/bfd/reloc.c index 626c818b09..b59ca00e97 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -4560,6 +4560,8 @@ ENUMX BFD_RELOC_RL78_HI8 ENUMX BFD_RELOC_RL78_LO16 +ENUMX + BFD_RELOC_RL78_CODE ENUMDOC Renesas RL78 Relocations. diff --git a/gas/ChangeLog b/gas/ChangeLog index 0014922e89..a7f4709870 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,11 @@ +2013-02-27 DJ Delorie + + * config/tc-rl78.c (reloc_function): Add %code -> BFD_RELOC_RL78_CODE. + (rl78_op): Handle %code(). + (rl78_cons_fix_new): Likewise, but ignore for 20-bit operands. + (tc_gen_reloc): Likwise; convert to a computed reloc. + (md_apply_fix): Likewise. + 2013-02-25 Kaushik Phatak * config/rl78-parse.y: Fix encoding of DIVWU insn. diff --git a/gas/config/tc-rl78.c b/gas/config/tc-rl78.c index bd964dc163..77a19bb507 100644 --- a/gas/config/tc-rl78.c +++ b/gas/config/tc-rl78.c @@ -194,6 +194,9 @@ rl78_op (expressionS exp, int nbytes, int type) } else { + if (nbytes > 2 + && exp.X_md == BFD_RELOC_RL78_CODE) + exp.X_md = 0; rl78_op_fixup (exp, rl78_bytes.n_ops * 8, nbytes * 8, type); memset (rl78_bytes.ops + rl78_bytes.n_ops, 0, nbytes); rl78_bytes.n_ops += nbytes; @@ -337,6 +340,7 @@ static struct } reloc_functions[] = { + { "code", BFD_RELOC_RL78_CODE }, { "lo16", BFD_RELOC_RL78_LO16 }, { "hi16", BFD_RELOC_RL78_HI16 }, { "hi8", BFD_RELOC_RL78_HI8 }, @@ -556,6 +560,10 @@ rl78_cons_fix_new (fragS * frag, switch (exp->X_md) { + case BFD_RELOC_RL78_CODE: + if (size == 2) + type = exp->X_md; + break; case BFD_RELOC_RL78_LO16: case BFD_RELOC_RL78_HI16: if (size != 2) @@ -665,6 +673,11 @@ tc_gen_reloc (asection * seg ATTRIBUTE_UNUSED, fixS * fixp) OP (ABS32); break; + case BFD_RELOC_RL78_CODE: + SYM0 (); + OP (ABS16); + break; + case BFD_RELOC_RL78_LO16: SYM0 (); OPIMM (0xffff); @@ -771,6 +784,7 @@ md_apply_fix (struct fix * f ATTRIBUTE_UNUSED, case BFD_RELOC_16: case BFD_RELOC_16_PCREL: + case BFD_RELOC_RL78_CODE: op[0] = val; op[1] = val >> 8; break; -- 2.34.1