aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorKuan-Lin Chen <rufus@andestech.com>2017-06-08 11:54:14 -0700
committerPalmer Dabbelt <palmer@dabbelt.com>2017-06-26 18:26:40 -0700
commita6cbf936e3dce68114d28cdf60d510a3f78a6d40 (patch)
treedc4fe23922098e657bdab1a1f749a36e6bf27e9c /bfd
parent7211ae501eb0de1044983f2dfb00091a58fbd66c (diff)
downloadgdb-a6cbf936e3dce68114d28cdf60d510a3f78a6d40.zip
gdb-a6cbf936e3dce68114d28cdf60d510a3f78a6d40.tar.gz
gdb-a6cbf936e3dce68114d28cdf60d510a3f78a6d40.tar.bz2
RISC-V: Use pc-relative relocation for FDE initial location
The symbol address in .eh_frame may be adjusted in _bfd_elf_discard_section_eh_frame, and the content of .eh_frame will be adjusted in _bfd_elf_write_section_eh_frame. Therefore, we cannot insert a relocation whose addend symbol is in .eh_frame. Othrewise, the value may be adjusted twice. bfd/ChangeLog 2017-06-26 Kuan-Lin Chen <rufus@andestech.com> * elfnn-riscv.c (perform_relocation): Support the new R_RISCV_32_PCREL relocation. (riscv_elf_relocate_section): Likewise. * elfxx-riscv.c (howto_table): Likewise. (riscv_reloc_map): Likewise. * bfd-in2.h (BFD_RELOC_RISCV_32_PCREL): New relocation. * libbfd.h: Regenerate. gas/ChangeLog 2017-06-26 Kuan-Lin Chen <rufus@andestech.com> * config/tc-riscv.c (md_apply_fix) [BFD_RELOC_32]: Convert to a R_RISCV_32_PCREL relocation. include/ChangeLog 2017-06-26 Kuan-Lin Chen <rufus@andestech.com> * elf/riscv.h (R_RISCV_32_PCREL): New.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/bfd-in2.h1
-rw-r--r--bfd/elfnn-riscv.c2
-rw-r--r--bfd/elfxx-riscv.c16
-rw-r--r--bfd/libbfd.h1
-rw-r--r--bfd/reloc.c2
6 files changed, 32 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f440f8f..3cab920 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+2017-06-26 Kuan-Lin Chen <rufus@andestech.com>
+
+ * elfnn-riscv.c (perform_relocation): Support the new
+ R_RISCV_32_PCREL relocation.
+ (riscv_elf_relocate_section): Likewise.
+ * elfxx-riscv.c (howto_table): Likewise.
+ (riscv_reloc_map): Likewise.
+ * bfd-in2.h (BFD_RELOC_RISCV_32_PCREL): New relocation.
+ * libbfd.h: Regenerate.
+
2017-06-27 Alan Modra <amodra@gmail.com>
PR binutils/21665
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 45f665b..8c312e3 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -4771,6 +4771,7 @@ number for the SBIC, SBIS, SBI and CBI instructions */
BFD_RELOC_RISCV_SET8,
BFD_RELOC_RISCV_SET16,
BFD_RELOC_RISCV_SET32,
+ BFD_RELOC_RISCV_32_PCREL,
/* Renesas RL78 Relocations. */
BFD_RELOC_RL78_NEG8,
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 4e3cf55..455f2ff 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -1566,6 +1566,7 @@ perform_relocation (const reloc_howto_type *howto,
case R_RISCV_SET8:
case R_RISCV_SET16:
case R_RISCV_SET32:
+ case R_RISCV_32_PCREL:
case R_RISCV_TLS_DTPREL32:
case R_RISCV_TLS_DTPREL64:
break;
@@ -1849,6 +1850,7 @@ riscv_elf_relocate_section (bfd *output_bfd,
case R_RISCV_SET8:
case R_RISCV_SET16:
case R_RISCV_SET32:
+ case R_RISCV_32_PCREL:
/* These require no special handling beyond perform_relocation. */
break;
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index 6936722..5fa98f3 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -833,6 +833,21 @@ static reloc_howto_type howto_table[] =
0, /* src_mask */
MINUS_ONE, /* dst_mask */
FALSE), /* pcrel_offset */
+
+ /* 32-bit PC relative. */
+ HOWTO (R_RISCV_32_PCREL, /* type */
+ 0, /* rightshift */
+ 2, /* size */
+ 32, /* bitsize */
+ TRUE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_RISCV_32_PCREL", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ FALSE), /* pcrel_offset */
};
/* A mapping from BFD reloc types to RISC-V ELF reloc types. */
@@ -894,6 +909,7 @@ static const struct elf_reloc_map riscv_reloc_map[] =
{ BFD_RELOC_RISCV_SET8, R_RISCV_SET8 },
{ BFD_RELOC_RISCV_SET16, R_RISCV_SET16 },
{ BFD_RELOC_RISCV_SET32, R_RISCV_SET32 },
+ { BFD_RELOC_RISCV_32_PCREL, R_RISCV_32_PCREL },
};
/* Given a BFD reloc type, return a howto structure. */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 09df3b2..ae9bf76 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -2215,6 +2215,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_RISCV_SET8",
"BFD_RELOC_RISCV_SET16",
"BFD_RELOC_RISCV_SET32",
+ "BFD_RELOC_RISCV_32_PCREL",
"BFD_RELOC_RL78_NEG8",
"BFD_RELOC_RL78_NEG16",
"BFD_RELOC_RL78_NEG24",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 024056f..aa70fa58 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -5155,6 +5155,8 @@ ENUMX
BFD_RELOC_RISCV_SET16
ENUMX
BFD_RELOC_RISCV_SET32
+ENUMX
+ BFD_RELOC_RISCV_32_PCREL
ENUMDOC
RISC-V relocations.