[ARC] Add JLI support.

The following relocation types were added to GCC/binutils:

ARC_JLI_SECTOFF is a relocation type in Metaware that is now used by
GCC as well to adjust the index of function calls to functions with
attribute jli_call_always.

bfd/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
	    John Eric Martin  <John.Martin@emmicro-us.com>

	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* elf32-arc.c (JLI): Define.
	* reloc.c: Add JLI relocations.

gas/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>

	* testsuite/gas/arc/jli-1.d: New file.
	* testsuite/gas/arc/jli-1.s: Likewise.
	* testsuite/gas/arc/taux.d: Update for jli_base.

include/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
	    John Eric Martin  <John.Martin@emmicro-us.com>

	* elf/arc-reloc.def: Add JLI relocs howto.
	* opcode/arc-func.h (replace_jli): New function.

ld/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
	    John Eric Martin  <John.Martin@emmicro-us.com>

	* emulparams/arcelf.sh (JLI_START_TABLE): Define.
	* scripttempl/elfarc.sc: Handle jlitab section.
	* scripttempl/elfarcv2.sc: Likewise.
	* testsuite/ld-arc/arc.exp: Add JLI test.
	* testsuite/ld-arc/jli-script.ld: New file.
	* testsuite/ld-arc/jli-simple.dd: Likewise.
	* testsuite/ld-arc/jli-simple.rd: Likewise.
	* testsuite/ld-arc/jli-simple.s: Likewise.
	* testsuite/ld/testsuite/ld-arc/jli-overflow.s: Likewise.
	* testsuite/ld/testsuite/ld-arc/jli-overflow.d: Likewise.
	* testsuite/ld/testsuite/ld-arc/jli-overflow.err: Likewise.

opcode/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
	    John Eric Martin  <John.Martin@emmicro-us.com>

	* arc-opc.c (UIMM10_6_S_JLIOFF): Define.
	(UIMM3_23): Adjust accordingly.
	* arc-regs.h: Add/correct jli_base register.
	* arc-tbl.h (jli_s): Likewise.
This commit is contained in:
John Eric Martin 2017-07-19 09:56:55 +02:00 committed by claziss
parent e4943f2c75
commit 684d5a10b1
30 changed files with 1274 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2017-07-19 Claudiu Zissulescu <claziss@synopsys.com>
John Eric Martin <John.Martin@emmicro-us.com>
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* elf32-arc.c (JLI): Define.
* reloc.c: Add JLI relocations.
2017-07-18 Nick Clifton <nickc@redhat.com>
PR 21775

View File

@ -3800,6 +3800,7 @@ pc-relative or some form of GOT-indirect relocation. */
BFD_RELOC_ARC_S25W_PCREL_PLT,
BFD_RELOC_ARC_S21H_PCREL_PLT,
BFD_RELOC_ARC_NPS_CMEM16,
BFD_RELOC_ARC_JLI_SECTOFF,
/* ADI Blackfin 16 bit immediate absolute reloc. */
BFD_RELOC_BFIN_16_IMM,

View File

@ -1182,7 +1182,7 @@ arc_special_overflow_checks (const struct arc_relocation_data reloc_data,
+ (reloc_data.reloc_offset))))
#define SECTSTART (bfd_signed_vma) (reloc_data.sym_section->output_section->vma \
+ reloc_data.sym_section->output_offset)
#define JLI (bfd_signed_vma) (reloc_data.sym_section->output_section->vma)
#define _SDA_BASE_ (bfd_signed_vma) (reloc_data.sdata_begin_symbol_vma)
#define TLS_REL (bfd_signed_vma) \
((elf_hash_table (info))->tls_sec->output_section->vma)
@ -1359,6 +1359,7 @@ arc_do_relocation (bfd_byte * contents,
#undef P
#undef SECTSTAR
#undef SECTSTART
#undef JLI
#undef _SDA_BASE_
#undef none

View File

@ -1752,6 +1752,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_ARC_S25W_PCREL_PLT",
"BFD_RELOC_ARC_S21H_PCREL_PLT",
"BFD_RELOC_ARC_NPS_CMEM16",
"BFD_RELOC_ARC_JLI_SECTOFF",
"BFD_RELOC_BFIN_16_IMM",
"BFD_RELOC_BFIN_16_HIGH",
"BFD_RELOC_BFIN_4_PCREL",

View File

@ -3695,6 +3695,8 @@ ENUMX
BFD_RELOC_ARC_S21H_PCREL_PLT
ENUMX
BFD_RELOC_ARC_NPS_CMEM16
ENUMX
BFD_RELOC_ARC_JLI_SECTOFF
ENUMDOC
ARC relocs.

View File

@ -1,3 +1,9 @@
2017-07-19 Claudiu Zissulescu <claziss@synopsys.com>
* testsuite/gas/arc/jli-1.d: New file.
* testsuite/gas/arc/jli-1.s: Likewise.
* testsuite/gas/arc/taux.d: Update for jli_base.
2017-07-19 Tristan Gingold <gingold@adacore.com>
* as.c (start_sbrk): Remove.

View File

@ -0,0 +1,25 @@
#as:
#objdump: -Dr
.*: +file format .*
Disassembly of section .group:
00000000 <jlitab.foo>:
0: 0[10] 00 00 0[01] .word 0x00000001
4: 0[60] 00 00 0[06] .word 0x00000006
Disassembly of section .text:
00000000 <.text>:
0: 5800 jli_s 0
0: R_ARC_JLI_SECTOFF __jli.foo
Disassembly of section .jlitab:
00000000 <__jli.foo>:
0: 0001 0000 b 0 <foo>
0: R_ARC_S25H_PCREL foo
#...

View File

@ -0,0 +1,11 @@
;;; Test basic JLI relocs and constructs.
.cpu em4
jli_s __jli.foo ; Generates R_ARC_JLI_SECTOFF
.section .jlitab,"axG",%progbits,jlitab.foo,comdat
.align 4
__jli.foo:
.weak __jli.foo
b @foo

View File

@ -16,6 +16,7 @@
.* U d2l
.* U dpfp_status
.* U fp_status
.* U jli_base
.* mx0
.* mx1
.* my0

View File

@ -1,3 +1,9 @@
2017-07-19 Claudiu Zissulescu <claziss@synopsys.com>
John Eric Martin <John.Martin@emmicro-us.com>
* elf/arc-reloc.def: Add JLI relocs howto.
* opcode/arc-func.h (replace_jli): New function.
2017-07-18 Nick Clifton <nickc@redhat.com>
PR 21775

View File

@ -414,6 +414,13 @@ ARC_RELOC_HOWTO(ARC_S25H_PCREL_PLT, 61, \
signed, \
( ME ( ( ( ( L + A ) - P ) >> 1 ) ) ))
ARC_RELOC_HOWTO(ARC_JLI_SECTOFF, 63, \
1, \
10, \
replace_jli, \
bitfield, \
( ( S - JLI ) >> 2))
ARC_RELOC_HOWTO(ARC_TLS_DTPMOD, 66, \
2, \
32, \

View File

@ -274,8 +274,21 @@ replace_disp12s (unsigned insn, int value ATTRIBUTE_UNUSED)
insn = insn & ~0xfff;
insn |= ((value >> 0) & 0x003f) << 6;
insn |= ((value >> 6) & 0x003f) << 0;
return insn;
}
#endif /* REPLACE_disp12s */
/* mask = 0000001111111111. */
#ifndef REPLACE_jli
#define REPLACE_jli
ATTRIBUTE_UNUSED static unsigned
replace_jli (unsigned insn, int value)
{
insn = insn & ~0x3ff;
insn |= ((value >> 0) & 0x03ff) << 0;
return insn;
}
#endif /* REPLACE_jli */

View File

@ -1,3 +1,18 @@
2017-07-19 Claudiu Zissulescu <claziss@synopsys.com>
John Eric Martin <John.Martin@emmicro-us.com>
* emulparams/arcelf.sh (JLI_START_TABLE): Define.
* scripttempl/elfarc.sc: Handle jlitab section.
* scripttempl/elfarcv2.sc: Likewise.
* testsuite/ld-arc/arc.exp: Add JLI test.
* testsuite/ld-arc/jli-script.ld: New file.
* testsuite/ld-arc/jli-simple.dd: Likewise.
* testsuite/ld-arc/jli-simple.rd: Likewise.
* testsuite/ld-arc/jli-simple.s: Likewise.
* testsuite/ld-arc/jli-overflow.s: Likewise.
* testsuite/ld-arc/jli-overflow.d: Likewise.
* testsuite/ld-arc/jli-overflow.err: Likewise.
2017-07-19 Tristan Gingold <gingold@adacore.com>
* ldmain.c (main): Remove display of data size.

View File

@ -16,6 +16,7 @@ ARCH=arc
MACHINE=
ENTRY=__start
SDATA_START_SYMBOLS='__SDATA_BEGIN__ = . + 0x100;'
JLI_START_TABLE='__JLI_TABLE__ = .;'
OTHER_SECTIONS="/DISCARD/ : { *(.__arc_profile_*) }"
EMBEDDED=yes

View File

@ -22,5 +22,6 @@ LITTLE_OUTPUT_FORMAT="elf32-littlearc"
BIG_OUTPUT_FORMAT="elf32-bigarc"
TEXT_START_ADDR=0x100
ENTRY=__start
SDATA_START_SYMBOLS='__SDATA_BEGIN__ = .;'
SDATA_START_SYMBOLS='__SDATA_BEGIN__ = . + 0x100;'
JLI_START_TABLE='__JLI_TABLE__ = .;'
OTHER_SECTIONS="/DISCARD/ : { *(.__arc_profile_*) }"

View File

@ -18,6 +18,7 @@ LITTLE_OUTPUT_FORMAT="elf32-littlearc"
BIG_OUTPUT_FORMAT="elf32-bigarc"
TEXT_START_ADDR=0x100
ENTRY=__start
SDATA_START_SYMBOLS='__SDATA_BEGIN__ = .;'
SDATA_START_SYMBOLS='__SDATA_BEGIN__ = . + 0x100;'
JLI_START_TABLE='__JLI_TABLE__ = .;'
OTHER_SECTIONS="/DISCARD/ : { *(.__arc_profile_*) }"
EMBEDDED=yes

View File

@ -262,6 +262,12 @@ cat <<EOF
} =${NOP-0}
${DATA_PLT-${BSS_PLT-${PLT}}}
.jlitab ${RELOCATING-0} :
{
${RELOCATING+${JLI_START_TABLE}}
jlitab*.o(.jlitab*)
*(.jlitab*)
} =${NOP-0}
.text ${RELOCATING-0} :
{
${RELOCATING+${TEXT_START_SYMBOLS}}

View File

@ -179,6 +179,11 @@ SECTIONS
.eh_frame : { KEEP (*(.eh_frame)) } ${RELOCATING+> ${TEXT_MEMORY}}
.gcc_except_table : { *(.gcc_except_table) *(.gcc_except_table.*) } ${RELOCATING+> ${TEXT_MEMORY}}
.plt : { *(.plt) } ${RELOCATING+> ${TEXT_MEMORY}}
.jlitab :
{
${RELOCATING+${JLI_START_TABLE}}
jlitab*.o:(.jlitab*) *(.jlitab*)
} ${RELOCATING+> ${TEXT_MEMORY}}
.rodata ${RELOCATING-0} :
{

View File

@ -40,6 +40,11 @@ set arccommon_tests {
{tls-dtpoff.s}
{{objdump -fdw tls-dtpoff.dd} {readelf --relocs tls-dtpoff.rd}}
"sda-relocs.so" }
{ "JLI simple"
"-q -T jli-script.ld -A elf32-arclittle" "" "-mcpu=em4 -EL"
{jli-simple.s}
{{objdump -fdw jli-simple.dd} {readelf --relocs jli-simple.rd}}
"jli-simple.so" }
}
run_ld_link_tests $arccommon_tests

View File

@ -0,0 +1,4 @@
#source: jli-overflow.s
#as:
#ld: -q -T jli-script.ld
#error_output: jli-overflow.err

View File

@ -0,0 +1,3 @@
.*\.o: In function `test_1025':
.*: relocation truncated to fit: R_ARC_JLI_SECTOFF against symbol.*
#...

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
/* Default linker script, for normal executables. */
OUTPUT_FORMAT("elf32-littlearc", "elf32-bigarc",
"elf32-littlearc")
OUTPUT_ARCH(arc)
ENTRY(__start)
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__start = 0x10000);
. = 0x10000 + SIZEOF_HEADERS;
.text : {*(.text .stub .text.*)} =0
.jlitab : {jlitab*.o(.jlitab*) *(.jlitab*) }
.tdata : {.tdata = .; *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : {.tbss = .; *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
/DISCARD/ : { *(.note.GNU-stack) }
}

View File

@ -0,0 +1,26 @@
.*: file format .*
architecture: ARCv2, flags 0x00000113:
HAS_RELOC, EXEC_P, HAS_SYMS, D_PAGED
start address 0x00010000
Disassembly of section .text:
00010054 <test>:
10054: 5800 jli_s 0
10056: 5801 jli_s 0x1
00010058 <foo>:
10058: 2000 0000 add r0,r0,r0
0001005c <bar>:
1005c: 2100 0080 add r0,r1,r2
Disassembly of section .jlitab:
00010060 <__jli.foo>:
10060: 07f9 ffcf b 10058 <foo>
00010064 <__jli.bar>:
10064: 07f9 ffcf b 1005c <bar>

View File

@ -0,0 +1,10 @@
Relocation section '\.rela\.text' .*:
Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
00010054 [0-9a-f]+ R_ARC_JLI_SECTOFF 00010060 __jli\.foo \+ 0
00010056 [0-9a-f]+ R_ARC_JLI_SECTOFF 00010064 __jli\.bar \+ 0
Relocation section '\.rela\.jlitab' .*:
Offset +Info +Type +Sym.Value +Sym. Name \+ Addend
00010060 [0-9a-f]+ R_ARC_S25H_PCREL 00010054 .text \+ 4
00010064 [0-9a-f]+ R_ARC_S25H_PCREL 00010054 .text \+ 8

View File

@ -0,0 +1,24 @@
.cpu em4
.text
.align 4
test:
jli_s __jli.foo
jli_s __jli.bar
.align 4
foo:
add r0,r0,r0
.align 4
bar:
add r0,r1,r2
.section .jlitab,"axG",%progbits,jli_group,comdat
.align 4
__jli.foo:
.weak __jli.foo
b @foo
.align 4
__jli.bar:
.weak __jli.bar
b @bar

View File

@ -1,3 +1,11 @@
2017-07-19 Claudiu Zissulescu <claziss@synopsys.com>
John Eric Martin <John.Martin@emmicro-us.com>
* arc-opc.c (UIMM10_6_S_JLIOFF): Define.
(UIMM3_23): Adjust accordingly.
* arc-regs.h: Add/correct jli_base register.
* arc-tbl.h (jli_s): Likewise.
2017-07-18 Nick Clifton <nickc@redhat.com>
PR 21775

View File

@ -2039,8 +2039,14 @@ const struct arc_operand arc_operands[] =
| ARC_OPERAND_TRUNCATE | ARC_OPERAND_PCREL, insert_simm8_a16_9_s,
extract_simm8_a16_9_s},
/* UIMM10_6_S_JLIOFF mask = 0000001111111111. */
#define UIMM10_6_S_JLIOFF (SIMM8_A16_9_S + 1)
{12, 0, BFD_RELOC_ARC_JLI_SECTOFF, ARC_OPERAND_UNSIGNED
| ARC_OPERAND_ALIGNED32 | ARC_OPERAND_TRUNCATE, insert_uimm10_6_s,
extract_uimm10_6_s},
/* UIMM3_23 mask = 00000000000000000000000111000000. */
#define UIMM3_23 (SIMM8_A16_9_S + 1)
#define UIMM3_23 (UIMM10_6_S_JLIOFF + 1)
{3, 0, 0, ARC_OPERAND_UNSIGNED, insert_uimm3_23, extract_uimm3_23},
/* UIMM10_6_S mask = 0000001111111111. */

View File

@ -69,7 +69,6 @@ DEF (0x23, ARC_OPCODE_ARCALL, NONE, limit0)
DEF (0x24, ARC_OPCODE_ARCALL, NONE, pcport)
DEF (0x25, ARC_OPCODE_ARCALL, NONE, int_vector_base)
DEF (0x26, ARC_OPCODE_ARCALL, NONE, aux_vbfdw_mode)
DEF (0x26, ARC_OPCODE_ARCALL, NONE, jli_base)
DEF (0x27, ARC_OPCODE_ARCALL, NONE, aux_vbfdw_bm0)
DEF (0x28, ARC_OPCODE_ARCALL, NONE, aux_vbfdw_bm1)
DEF (0x29, ARC_OPCODE_ARCALL, NONE, aux_vbfdw_accu)
@ -261,6 +260,7 @@ DEF (0x236, ARC_OPCODE_ARCALL, NONE, ap_amm7)
DEF (0x237, ARC_OPCODE_ARCALL, NONE, ap_ac7)
DEF (0x278, ARC_OPCODE_ARCALL, NONE, pct_control)
DEF (0x279, ARC_OPCODE_ARCALL, NONE, pct_bank)
DEF (0x290, ARC_OPCODE_ARCV2, NONE, jli_base)
DEF (0x300, ARC_OPCODE_ARCFPX, DPX, fp_status)
DEF (0x301, ARC_OPCODE_ARCFPX, DPX, aux_dpfp1l)
DEF (0x301, ARC_OPCODE_ARCFPX, DPX, d1l)

View File

@ -7955,6 +7955,7 @@
/* jli_s u10 010110uuuuuuuuuu. */
{ "jli_s", 0x00005800, 0x0000FC00, ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS, JLI, CD1, { UIMM10_6_S }, { 0 }},
{ "jli_s", 0x00005800, 0x0000FC00, ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS, JLI, CD1, { UIMM10_6_S_JLIOFF }, { 0 }},
/* jl_s b 01111bbb01000000. */
{ "jl_s", 0x00007840, 0x0000F8FF, ARC_OPCODE_ARC600 | ARC_OPCODE_ARC700, JUMP, NONE, { BRAKET, RB_S, BRAKETdup }, { 0 }},