+2018-09-27 Jim Wilson <jimw@sifive.com>
+
+ * elfnn-riscv.c (riscv_init_pcgp_relocs): Add explanatory comment.
+ (riscv_free_pcgp_relocs, riscv_record_pcgp_reloc): Likewise.
+ (riscv_find_pcgp_hi_reloc, riscv_reocrd_pcgp_lo_reloc): Likewise.
+ (riscv_find_pcgp_lo_reloc): Likewise.
+ (riscv_delete_pcgp_hi_reloc, riscv_use_pcgp_hi_reloc): Delete.
+ (riscv_delete_pcgp_lo_reloc): Likewise.
+ (_bfd_riscv_relax_pc): Don't call riscv_use_pcgp_hi_reloc. Replace
+ calls to riscv_delete_pcgp_lo_reloc and riscv_delete_pcgp_hi_reloc
+ with TRUE. Mark abfd arg as ATTRIBUTE_UNUSED.
+
2018-09-25 Jim Wilson <jimw@sifive.com>
* elfnn-riscv.c (riscv_make_plt_header): New arg output_bfd. Change
riscv_pcgp_lo_reloc *lo;
} riscv_pcgp_relocs;
+/* Initialize the pcgp reloc info in P. */
+
static bfd_boolean
riscv_init_pcgp_relocs (riscv_pcgp_relocs *p)
{
return TRUE;
}
+/* Free the pcgp reloc info in P. */
+
static void
riscv_free_pcgp_relocs (riscv_pcgp_relocs *p,
bfd *abfd ATTRIBUTE_UNUSED,
}
}
+/* Record pcgp hi part reloc info in P, using HI_SEC_OFF as the lookup index.
+ The HI_ADDEND, HI_ADDR, HI_SYM, and SYM_SEC args contain info required to
+ relax the corresponding lo part reloc. */
+
static bfd_boolean
riscv_record_pcgp_hi_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off,
bfd_vma hi_addend, bfd_vma hi_addr,
return TRUE;
}
+/* Look up hi part pcgp reloc info in P, using HI_SEC_OFF as the lookup index.
+ This is used by a lo part reloc to find the corresponding hi part reloc. */
+
static riscv_pcgp_hi_reloc *
riscv_find_pcgp_hi_reloc(riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
{
return NULL;
}
-static bfd_boolean
-riscv_delete_pcgp_hi_reloc(riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
-{
- bfd_boolean out = FALSE;
- riscv_pcgp_hi_reloc *c;
-
- for (c = p->hi; c != NULL; c = c->next)
- if (c->hi_sec_off == hi_sec_off)
- out = TRUE;
-
- return out;
-}
-
-static bfd_boolean
-riscv_use_pcgp_hi_reloc(riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
-{
- bfd_boolean out = FALSE;
- riscv_pcgp_hi_reloc *c;
-
- for (c = p->hi; c != NULL; c = c->next)
- if (c->hi_sec_off == hi_sec_off)
- out = TRUE;
-
- return out;
-}
+/* Record pcgp lo part reloc info in P, using HI_SEC_OFF as the lookup info.
+ This is used to record relocs that can't be relaxed. */
static bfd_boolean
riscv_record_pcgp_lo_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
return TRUE;
}
+/* Look up lo part pcgp reloc info in P, using HI_SEC_OFF as the lookup index.
+ This is used by a hi part reloc to find the corresponding lo part reloc. */
+
static bfd_boolean
riscv_find_pcgp_lo_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off)
{
return FALSE;
}
-static bfd_boolean
-riscv_delete_pcgp_lo_reloc (riscv_pcgp_relocs *p ATTRIBUTE_UNUSED,
- bfd_vma lo_sec_off ATTRIBUTE_UNUSED,
- size_t bytes ATTRIBUTE_UNUSED)
-{
- return TRUE;
-}
-
typedef bfd_boolean (*relax_func_t) (bfd *, asection *, asection *,
struct bfd_link_info *,
Elf_Internal_Rela *,
/* Relax PC-relative references to GP-relative references. */
static bfd_boolean
-_bfd_riscv_relax_pc (bfd *abfd,
+_bfd_riscv_relax_pc (bfd *abfd ATTRIBUTE_UNUSED,
asection *sec,
asection *sym_sec,
struct bfd_link_info *link_info,
hi_reloc = *hi;
symval = hi_reloc.hi_addr;
sym_sec = hi_reloc.sym_sec;
- if (!riscv_use_pcgp_hi_reloc(pcgp_relocs, hi->hi_sec_off))
- _bfd_error_handler
- (_("%pB(%pA+%#" PRIx64 "): Unable to clear RISCV_PCREL_HI20 reloc "
- "for corresponding RISCV_PCREL_LO12 reloc"),
- abfd, sec, (uint64_t) rel->r_offset);
}
break;
case R_RISCV_PCREL_LO12_I:
rel->r_info = ELFNN_R_INFO (sym, R_RISCV_GPREL_I);
rel->r_addend += hi_reloc.hi_addend;
- return riscv_delete_pcgp_lo_reloc (pcgp_relocs, rel->r_offset, 4);
+ return TRUE;
case R_RISCV_PCREL_LO12_S:
rel->r_info = ELFNN_R_INFO (sym, R_RISCV_GPREL_S);
rel->r_addend += hi_reloc.hi_addend;
- return riscv_delete_pcgp_lo_reloc (pcgp_relocs, rel->r_offset, 4);
+ return TRUE;
case R_RISCV_PCREL_HI20:
riscv_record_pcgp_hi_reloc (pcgp_relocs,
/* We can delete the unnecessary AUIPC and reloc. */
rel->r_info = ELFNN_R_INFO (0, R_RISCV_DELETE);
rel->r_addend = 4;
- return riscv_delete_pcgp_hi_reloc (pcgp_relocs, rel->r_offset);
+ return TRUE;
default:
abort ();