Adds support to the RL78 port for linker relaxation affecting .debug sections.

gas	* config/tc-rl78.h (TC_LINKRELAX_FIXUP): Define.
	(TC_FORCE_RELOCATION_SUB_SAME): Define.
	(DWARF2_USE_FIXED_ADVANCE_PC): Define.

	* gas/lns/lns.exp: Add RL78 to list of targets using
	DW_LNS_fixed_advance_pc.

bfd	* elf32-rl78.c (RL78_OP_REL): New macro.
	(rl78_elf_howto_table): Use it for complex relocs.
	(get_symbol_value): Handle the cases when the info or status
	arguments are NULL.
	(get_romstart): Cache the status returned by get_symbol_value.
	(get_ramstart): Likewise.
	(RL78_STACK_PUSH): Generate an error message if the stack
	overflows.
	(RL78_STACK_POP): Likewise for underflows.
	(rl78_compute_complex_reloc): New function.  Contains the basic
	processing code for all RL78 complex relocs.
	(rl78_special_reloc): New function.  Provides special reloc
	handling for complex relocs.
	(rl78_elf_relocate_section): Use rl78_compute_complex_reloc.
	(rl78_offset_for_reloc): Likewise.

binutils* readelf.c (target_specific_reloc_handling): Add code to handle
	RL78 complex relocs.
This commit is contained in:
Nick Clifton 2015-04-14 16:23:33 +01:00
parent 9e811bc379
commit 6ff71e7681
9 changed files with 582 additions and 427 deletions

View file

@ -1,3 +1,21 @@
2015-04-14 Nick Clifton <nickc@redhat.com>
* elf32-rl78.c (RL78_OP_REL): New macro.
(rl78_elf_howto_table): Use it for complex relocs.
(get_symbol_value): Handle the cases when the info or status
arguments are NULL.
(get_romstart): Cache the status returned by get_symbol_value.
(get_ramstart): Likewise.
(RL78_STACK_PUSH): Generate an error message if the stack
overflows.
(RL78_STACK_POP): Likewise for underflows.
(rl78_compute_complex_reloc): New function. Contains the basic
processing code for all RL78 complex relocs.
(rl78_special_reloc): New function. Provides special reloc
handling for complex relocs.
(rl78_elf_relocate_section): Use rl78_compute_complex_reloc.
(rl78_offset_for_reloc): Likewise.
2015-04-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/pr17709

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,8 @@
2015-04-14 Nick Clifton <nickc@redhat.com>
* readelf.c (target_specific_reloc_handling): Add code to handle
RL78 complex relocs.
2015-04-13 Doug Evans <dje@google.com>
PR binutils/18218

View file

@ -11161,6 +11161,42 @@ target_specific_reloc_handling (Elf_Internal_Rela * reloc,
}
break;
}
case EM_RL78:
{
static bfd_vma saved_sym1 = 0;
static bfd_vma saved_sym2 = 0;
static bfd_vma value;
switch (reloc_type)
{
case 0x80: /* R_RL78_SYM. */
saved_sym1 = saved_sym2;
saved_sym2 = symtab[get_reloc_symindex (reloc->r_info)].st_value;
saved_sym2 += reloc->r_addend;
return TRUE;
case 0x83: /* R_RL78_OPsub. */
value = saved_sym1 - saved_sym2;
saved_sym2 = saved_sym1 = 0;
return TRUE;
break;
case 0x41: /* R_RL78_ABS32. */
byte_put (start + reloc->r_offset, value, 4);
value = 0;
return TRUE;
case 0x43: /* R_RL78_ABS16. */
byte_put (start + reloc->r_offset, value, 2);
value = 0;
return TRUE;
default:
break;
}
break;
}
}
return FALSE;

View file

@ -1,3 +1,9 @@
2015-04-14 Nick Clifton <nickc@redhat.com>
* config/tc-rl78.h (TC_LINKRELAX_FIXUP): Define.
(TC_FORCE_RELOCATION_SUB_SAME): Define.
(DWARF2_USE_FIXED_ADVANCE_PC): Define.
2015-04-10 Nick Clifton <nickc@redhat.com>
PR binutils/18198

View file

@ -340,15 +340,16 @@ md_parse_option (int c, char * arg ATTRIBUTE_UNUSED)
}
void
md_show_usage (FILE * stream ATTRIBUTE_UNUSED)
md_show_usage (FILE * stream)
{
fprintf (stream, _(" RL78 specific command line options:\n"));
fprintf (stream, _(" --mrelax Enable link time relaxation\n"));
fprintf (stream, _(" --mg10 Enable support for G10 variant\n"));
fprintf (stream, _(" --mg13 Selects the G13 core.\n"));
fprintf (stream, _(" --mg14 Selects the G14 core [default]\n"));
fprintf (stream, _(" --mrl78 Alias for --mg14\n"));
fprintf (stream, _(" --m32bit-doubles [default]\n"));
fprintf (stream, _(" --m64bit-doubles\n"));
fprintf (stream, _(" --m64bit-doubles Source code uses 64-bit doubles\n"));
}
static void
@ -662,13 +663,23 @@ rl78_cons_fix_new (fragS * frag,
case BFD_RELOC_RL78_LO16:
case BFD_RELOC_RL78_HI16:
if (size != 2)
as_bad (_("%%hi16/%%lo16 only applies to .short or .hword"));
type = exp->X_md;
{
/* Fixups to assembler generated expressions do not use %hi or %lo. */
if (frag->fr_file)
as_bad (_("%%hi16/%%lo16 only applies to .short or .hword"));
}
else
type = exp->X_md;
break;
case BFD_RELOC_RL78_HI8:
if (size != 1)
as_bad (_("%%hi8 only applies to .byte"));
type = exp->X_md;
{
/* Fixups to assembler generated expressions do not use %hi or %lo. */
if (frag->fr_file)
as_bad (_("%%hi8 only applies to .byte"));
}
else
type = exp->X_md;
break;
default:
break;
@ -823,7 +834,7 @@ rl78_frag_fix_value (fragS * fragP,
/* Estimate how big the opcode is after this relax pass. The return
value is the difference between fr_fix and the actual size. We
compute the total size in rl78_relax_frag and store it in fr_subtype,
sowe only need to subtract fx_fix and return it. */
so we only need to subtract fx_fix and return it. */
int
md_estimate_size_before_relax (fragS * fragP ATTRIBUTE_UNUSED, segT segment ATTRIBUTE_UNUSED)
@ -960,8 +971,8 @@ rl78_relax_frag (segT segment ATTRIBUTE_UNUSED, fragS * fragP, long stretch)
fragP->fr_subtype = newsize;
tprintf (" -> new %d old %d delta %d\n", newsize, oldsize, newsize-oldsize);
return newsize - oldsize;
}
}
/* This lets us test for the opcode type and the desired size in a
switch statement. */
#define OPCODE(type,size) ((type) * 16 + (size))

View file

@ -85,3 +85,17 @@ extern void rl78_elf_final_processing (void);
#define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
((EXP)->X_md = 0, expression (EXP), TC_PARSE_CONS_RETURN_NONE)
#define TC_LINKRELAX_FIXUP(seg) ((seg->flags & SEC_CODE) || (seg->flags & SEC_DEBUGGING))
/* Do not adjust relocations involving symbols in code sections,
because it breaks linker relaxations. This could be fixed in the
linker, but this fix is simpler, and it pretty much only affects
object size a little bit. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
( ((SEC)->flags & SEC_CODE) != 0 \
|| ((SEC)->flags & SEC_DEBUGGING) != 0 \
|| ! SEG_NORMAL (SEC) \
|| TC_FORCE_RELOCATION (FIX))
#define DWARF2_USE_FIXED_ADVANCE_PC 1

View file

@ -1,3 +1,8 @@
2015-04-14 Nick Clifton <nickc@redhat.com>
* gas/lns/lns.exp: Add RL78 to list of targets using
DW_LNS_fixed_advance_pc.
2015-04-08 H.J. Lu <hongjiu.lu@intel.com>
* gas/i386/dw2-compressed-1.d: New file.

View file

@ -32,13 +32,14 @@ if {
&& ![istarget s390*-*-*]
} {
# Use alternate file for targets using DW_LNS_fixed_advance_pc opcodes.
if { [istarget xtensa*-*-*]
|| [istarget am3*-*-*]
if { [istarget am3*-*-*]
|| [istarget cr16-*-*]
|| [istarget crx-*-*]
|| [istarget mn10*-*-*]
|| [istarget msp430-*-*]
|| [istarget nds32*-*-*]
|| [istarget mn10*-*-*] } {
|| [istarget rl78-*-*]
|| [istarget xtensa*-*-*] } {
run_dump_test "lns-common-1-alt"
run_dump_test "lns-big-delta"
} elseif { [istarget ia64*-*-*] } {