This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] CSKY: About PC relative diff relocation
- From: Lifang Xia <lifang_xia at c-sky dot com>
- To: binutils at sourceware dot org
- Cc: Sandra Loosemore <sandra at codesourcery dot com>, 尚云海 <yunhai_shang at c-sky dot com>, 瞿仙淼 <xianmiao_qu at c-sky dot com>
- Date: Mon, 10 Sep 2018 10:09:50 +0800
- Subject: [PATCH] CSKY: About PC relative diff relocation
Hi everyone,
Here is a patch about PC relative diff relocation in CSKY.
bfd:
* elf32-csky.c (csky_elf_howto_table): Fill special_function of
R_CKCORE_PCREL32.
(csky_elf_relocate_section): Add R_CKCORE_PCREL32 process.
gas:
* config/tc-csky.c (md_apply_fix): Transmit
BFD_RELOC_32_PCREL to BFD_RELOC_CKCORE_PCREL32.
(tc_gen_reloc): Trasmit BFD_RELOC_CKCORE_ADDR32 to
BFD_RELOC_CKCORE_PCREL32 while pc-relative.
* config/tc-csky.h (DIFF_EXPR_OK): Define to enable PC relative
diff relocs.
Can anyone review and commit it?
Thanks.
Lifang.
commit f5b0cb0f62b371bac311c56b19189950b41d01f0
Author: Lifang Xia <lifang_xia@c-sky.com>
Date: Mon Sep 10 09:38:56 2018 +0800
csky: Support PC relative diff relocation
Define DIFF_EXPR_OK to Support PC relative diff relocation,
and add CKCORE_PCREL32 relocation process
bfd:
* elf32-csky.c (csky_elf_howto_table): Fill special_function of
R_CKCORE_PCREL32.
(csky_elf_relocate_section): Add R_CKCORE_PCREL32 process.
gas:
* config/tc-csky.c (md_apply_fix): Transmit
BFD_RELOC_32_PCREL to BFD_RELOC_CKCORE_PCREL32.
(tc_gen_reloc): Trasmit BFD_RELOC_CKCORE_ADDR32 to
BFD_RELOC_CKCORE_PCREL32 while pc-relative.
* config/tc-csky.h (DIFF_EXPR_OK): Define to enable PC relative
diff relocs.
Change-Id: Ief8739be95944fbb3b582238ecf779036b5f72b2
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a4991050cd..afa1db6dfc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2018-09-10 Lifang Xia <lifang_xia@c-sky.com>
+
+ * elf32-csky.c (csky_elf_howto_table): Fill special_function of
+ R_CKCORE_PCREL32.
+ (csky_elf_relocate_section): Add R_CKCORE_PCREL32 process.
+
2018-09-06 Alan Modra <amodra@gmail.com>
PR 23570
diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c
index d406b5a624..926166efd0 100644
--- a/bfd/elf32-csky.c
+++ b/bfd/elf32-csky.c
@@ -150,7 +150,7 @@ static reloc_howto_type csky_elf_howto_table[] =
TRUE, /* pc_relative */
0, /* bitpos */
complain_overflow_dont, /* complain_on_overflow */
- NULL, /* special_function */
+ bfd_elf_generic_reloc, /* special_function */
"R_CKCORE_PCREL32", /* name */
FALSE, /* partial_inplace */
0x0, /* src_mask */
@@ -4307,6 +4307,10 @@ csky_elf_relocate_section (bfd * output_bfd,
if (h == NULL && (addend & 0x80000000))
addend &= 0xffffffff;
break;
+
+ case R_CKCORE_PCREL32:
+ break;
+
case R_CKCORE_GOT12:
case R_CKCORE_PLT12:
case R_CKCORE_GOT_HI16:
@@ -5027,6 +5031,7 @@ csky_elf_relocate_section (bfd * output_bfd,
if (howto->size == 2
&& (howto->type == R_CKCORE_ADDR32
+ || howto->type == R_CKCORE_PCREL32
|| howto->type == R_CKCORE_GOT32
|| howto->type == R_CKCORE_GOTOFF
|| howto->type == R_CKCORE_GOTPC
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 310bf6eb33..5b9421abab 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,11 @@
+2018-09-10 Lifang Xia <lifang_xia@c-sky.com>
+ * config/tc-csky.c (md_apply_fix): Transmit BFD_RELOC_32_PCREL to
+ BFD_RELOC_CKCORE_PCREL32.
+ (tc_gen_reloc): Trasmit BFD_RELOC_CKCORE_ADDR32 to
+ BFD_RELOC_CKCORE_PCREL32 while pc-relative.
+ * config/tc-csky.h (DIFF_EXPR_OK): Define to enable PC relative diff
+ relocs.
+
2018-09-06 Alan Modra <amodra@gmail.com>
PR 23570
diff --git a/gas/config/tc-csky.c b/gas/config/tc-csky.c
index bd0672f77c..1c4b44b209 100644
--- a/gas/config/tc-csky.c
+++ b/gas/config/tc-csky.c
@@ -4920,7 +4920,9 @@ md_apply_fix (fixS *fixP,
/* We can handle these relocs. */
switch (fixP->fx_r_type)
{
+ case BFD_RELOC_32_PCREL:
case BFD_RELOC_CKCORE_PCREL32:
+ fixP->fx_r_type = BFD_RELOC_CKCORE_PCREL32;
break;
case BFD_RELOC_VTABLE_INHERIT:
fixP->fx_r_type = BFD_RELOC_CKCORE_GNU_VTINHERIT;
@@ -5133,6 +5135,10 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP)
{
arelent *rel;
+ if (fixP->fx_pcrel
+ && fixP->fx_r_type == BFD_RELOC_CKCORE_ADDR32)
+ fixP->fx_r_type = BFD_RELOC_CKCORE_PCREL32;
+
rel = xmalloc (sizeof (arelent));
rel->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
*rel->sym_ptr_ptr = symbol_get_bfdsym (fixP->fx_addsy);
diff --git a/gas/config/tc-csky.h b/gas/config/tc-csky.h
index 4ea0c03331..bb70ca2431 100644
--- a/gas/config/tc-csky.h
+++ b/gas/config/tc-csky.h
@@ -62,6 +62,9 @@
#define DWARF2_DEFAULT_RETURN_COLUMN 15
#define DWARF2_CIE_DATA_ALIGNMENT (-4)
+/* .-foo gets turned into PC relative relocs. */
+#define DIFF_EXPR_OK 1
+
typedef enum
{
MAP_UNDEFINED = 0,