Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
I dropped the addend fix
Browse files Browse the repository at this point in the history
  • Loading branch information
palmer-dabbelt committed May 16, 2017
1 parent afebc1d commit ce1d85a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bfd/elfnn-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2707,6 +2707,7 @@ typedef struct riscv_pcgp_hi_reloc riscv_pcgp_hi_reloc;
struct riscv_pcgp_hi_reloc
{
bfd_vma hi_sec_off;
bfd_vma hi_addend;
bfd_vma hi_addr;
unsigned hi_sym;
asection *sym_sec;
Expand Down Expand Up @@ -2754,12 +2755,14 @@ riscv_free_pcgp_relocs (riscv_pcgp_relocs *p, bfd *abfd, asection *sec)

static bfd_boolean
riscv_record_pcgp_hi_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off,
bfd_vma hi_addr, unsigned hi_sym, asection *sym_sec)
bfd_vma hi_addend, bfd_vma hi_addr,
unsigned hi_sym, asection *sym_sec)
{
riscv_pcgp_hi_reloc *new = bfd_malloc (sizeof(*new));
if (!new)
return FALSE;
new->hi_sec_off = hi_sec_off;
new->hi_addend = hi_addend;
new->hi_addr = hi_addr;
new->hi_sym = hi_sym;
new->sym_sec = sym_sec;
Expand Down Expand Up @@ -3173,7 +3176,7 @@ _bfd_riscv_relax_pc (bfd *abfd,
/* If gp and the symbol are in the same output section, then
consider only that section's alignment. */
struct bfd_link_hash_entry *h =
bfd_link_hash_lookup (link_info->hash, GP_NAME, FALSE, FALSE, TRUE);
bfd_link_hash_lookup (link_info->hash, RISCV_GP_SYMBOL, FALSE, FALSE, TRUE);
if (h->u.def.section->output_section == sym_sec->output_section)
max_alignment = (bfd_vma) 1 << sym_sec->output_section->alignment_power;
}
Expand All @@ -3191,15 +3194,21 @@ _bfd_riscv_relax_pc (bfd *abfd,
{
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);

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);

case R_RISCV_PCREL_HI20:
riscv_record_pcgp_hi_reloc (pcgp_relocs, rel->r_offset, symval,
ELFNN_R_SYM(rel->r_info), sym_sec);
riscv_record_pcgp_hi_reloc (pcgp_relocs,
rel->r_offset,
rel->r_addend,
symval,
ELFNN_R_SYM(rel->r_info),
sym_sec);
/* We can delete the unnecessary AUIPC and reloc. */
rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE);
*again = TRUE;
Expand Down

0 comments on commit ce1d85a

Please sign in to comment.