static bfd_boolean nds32_elf_merge_private_bfd_data
(bfd *, struct bfd_link_info *);
static bfd_boolean nds32_elf_print_private_bfd_data (bfd *, void *);
-static bfd_boolean nds32_elf_gc_sweep_hook
- (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
static bfd_boolean nds32_elf_check_relocs
(bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
static asection *nds32_elf_gc_mark_hook
}
}
- if (add_symbol == TRUE)
+ if (add_symbol)
{
if (h)
{
if (htab->root.dynamic_sections_created)
{
/* Set the contents of the .interp section to the interpreter. */
- if (!bfd_link_pic (info) && !info->nointerp)
+ if (bfd_link_executable (info) && !info->nointerp)
{
s = bfd_get_section_by_name (dynobj, ".interp");
BFD_ASSERT (s != NULL);
if (bfd_link_pic (info))
{
_bfd_error_handler
- (_("%s: warning: cannot deal R_NDS32_25_ABS_RELA in shared "
- "mode."), bfd_get_filename (input_bfd));
+ (_("%B: warning: cannot deal R_NDS32_25_ABS_RELA in shared "
+ "mode."), input_bfd);
return FALSE;
}
break;
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
}
-static bfd_boolean
-nds32_elf_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, asection *sec,
- const Elf_Internal_Rela *relocs)
-{
- /* Update the got entry reference counts for the section being removed. */
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- bfd_signed_vma *local_got_refcounts;
- const Elf_Internal_Rela *rel, *relend;
-
- elf_section_data (sec)->local_dynrel = NULL;
-
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (abfd);
- local_got_refcounts = elf_local_got_refcounts (abfd);
-
- relend = relocs + sec->reloc_count;
- for (rel = relocs; rel < relend; rel++)
- {
- unsigned long r_symndx;
- struct elf_link_hash_entry *h = NULL;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
- if (r_symndx >= symtab_hdr->sh_info)
- {
- /* External symbol. */
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (h->root.type == bfd_link_hash_indirect
- || h->root.type == bfd_link_hash_warning)
- h = (struct elf_link_hash_entry *) h->root.u.i.link;
- }
-
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_NDS32_GOT_HI20:
- case R_NDS32_GOT_LO12:
- case R_NDS32_GOT_LO15:
- case R_NDS32_GOT_LO19:
- case R_NDS32_GOT17S2_RELA:
- case R_NDS32_GOT15S2_RELA:
- case R_NDS32_GOTOFF:
- case R_NDS32_GOTOFF_HI20:
- case R_NDS32_GOTOFF_LO12:
- case R_NDS32_GOTOFF_LO15:
- case R_NDS32_GOTOFF_LO19:
- case R_NDS32_GOT20:
- case R_NDS32_GOTPC_HI20:
- case R_NDS32_GOTPC_LO12:
- case R_NDS32_GOTPC20:
- if (h != NULL)
- {
- if (h->got.refcount > 0)
- h->got.refcount--;
- }
- else
- {
- if (local_got_refcounts && local_got_refcounts[r_symndx] > 0)
- local_got_refcounts[r_symndx]--;
- }
- break;
-
- case R_NDS32_16_RELA:
- case R_NDS32_20_RELA:
- case R_NDS32_5_RELA:
- case R_NDS32_32_RELA:
- case R_NDS32_HI20_RELA:
- case R_NDS32_LO12S3_RELA:
- case R_NDS32_LO12S2_RELA:
- case R_NDS32_LO12S2_DP_RELA:
- case R_NDS32_LO12S2_SP_RELA:
- case R_NDS32_LO12S1_RELA:
- case R_NDS32_LO12S0_RELA:
- case R_NDS32_LO12S0_ORI_RELA:
- case R_NDS32_SDA16S3_RELA:
- case R_NDS32_SDA17S2_RELA:
- case R_NDS32_SDA18S1_RELA:
- case R_NDS32_SDA19S0_RELA:
- case R_NDS32_SDA15S3_RELA:
- case R_NDS32_SDA15S2_RELA:
- case R_NDS32_SDA12S2_DP_RELA:
- case R_NDS32_SDA12S2_SP_RELA:
- case R_NDS32_SDA15S1_RELA:
- case R_NDS32_SDA15S0_RELA:
- case R_NDS32_SDA_FP7U2_RELA:
- case R_NDS32_15_PCREL_RELA:
- case R_NDS32_17_PCREL_RELA:
- case R_NDS32_25_PCREL_RELA:
- if (h != NULL)
- {
- struct elf_nds32_link_hash_entry *eh;
- struct elf_nds32_dyn_relocs **pp;
- struct elf_nds32_dyn_relocs *p;
-
- if (!bfd_link_pic (info) && h->plt.refcount > 0)
- h->plt.refcount -= 1;
-
- eh = (struct elf_nds32_link_hash_entry *) h;
-
- for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
- if (p->sec == sec)
- {
- if (ELF32_R_TYPE (rel->r_info) == R_NDS32_15_PCREL_RELA
- || ELF32_R_TYPE (rel->r_info) == R_NDS32_17_PCREL_RELA
- || ELF32_R_TYPE (rel->r_info) == R_NDS32_25_PCREL_RELA)
- p->pc_count -= 1;
- p->count -= 1;
- if (p->count == 0)
- *pp = p->next;
- break;
- }
- }
- break;
-
- case R_NDS32_9_PLTREL:
- case R_NDS32_25_PLTREL:
- if (h != NULL)
- {
- if (h->plt.refcount > 0)
- h->plt.refcount--;
- }
- break;
-
- default:
- break;
- }
- }
-
- return TRUE;
-}
-
/* Look through the relocs for a section during the first phase.
Since we don't do .gots or .plts, we just need to consider the
virtual table relocs for gc. */
if (!IS_WITHIN_S (N32_IMM14S (insn), 8))
goto done;
- if ((insn & __BIT (14)) == 0)
+ if ((insn & N32_BIT (14)) == 0)
{
/* N32_BR1_BEQ */
if (N32_IS_RT3 (insn) && N32_RA5 (insn) == REG_R5
break;
case N32_OP6_JI:
- if ((insn & __BIT (24)) == 0)
+ if ((insn & N32_BIT (24)) == 0)
{
/* N32_JI_J */
if (IS_WITHIN_S (N32_IMM24S (insn), 8))
insn = N32_TYPE2 (SLTI, REG_TA, N16_RT4 (insn16), N16_IMM5U (insn16));
goto done;
case 0x34: /* beqzs8, bnezs8 */
- if (insn16 & __BIT (8))
+ if (insn16 & N32_BIT (8))
insn = N32_BR2 (BNEZ, REG_TA, N16_IMM8S (insn16));
else
insn = N32_BR2 (BEQZ, REG_TA, N16_IMM8S (insn16));
switch (__GF (insn16, 11, 4))
{
case 0x7: /* lwi37.fp/swi37.fp */
- if (insn16 & __BIT (7)) /* swi37.fp */
+ if (insn16 & N32_BIT (7)) /* swi37.fp */
insn = N32_TYPE2 (SWI, N16_RT38 (insn16), REG_FP, N16_IMM7U (insn16));
else /* lwi37.fp */
insn = N32_TYPE2 (LWI, N16_RT38 (insn16), REG_FP, N16_IMM7U (insn16));
break;
case N32_OP6_LBSI:
/* lbsi.gp */
- oinsn = N32_TYPE1 (LBGP, N32_RT5 (insn), __BIT (19));
+ oinsn = N32_TYPE1 (LBGP, N32_RT5 (insn), N32_BIT (19));
break;
case N32_OP6_SBI:
/* sbi.gp */
break;
case N32_OP6_ORI:
/* addi.gp */
- oinsn = N32_TYPE1 (SBGP, N32_RT5 (insn), __BIT (19));
+ oinsn = N32_TYPE1 (SBGP, N32_RT5 (insn), N32_BIT (19));
break;
}
break;
break;
case N32_OP6_LHSI:
/* lhsi.gp */
- oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), __BIT (18));
+ oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), N32_BIT (18));
break;
case N32_OP6_SHI:
/* shi.gp */
- oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), __BIT (19));
+ oinsn = N32_TYPE1 (HWGP, N32_RT5 (insn), N32_BIT (19));
break;
}
break;
unsigned long before, between;
bfd_byte *endp, *p;
- val = read_unsigned_leb128 (abfd, contents + irel->r_offset,
- &len);
+ val = _bfd_read_unsigned_leb128 (abfd, contents + irel->r_offset,
+ &len);
before = get_nds32_elf_blank_total (&blank_t, irel->r_addend, 0);
between = get_nds32_elf_blank_total (&blank_t,
static const char * unrecognized_reloc_msg =
/* xgettext:c-format */
- N_("%B: warning: %s points to unrecognized reloc at 0x%lx.");
+ N_("%B: warning: %s points to unrecognized reloc at %#Lx");
/* Relax LONGCALL1 relocation for nds32_elf_relax_section. */
if (hi_irelfn == irelend || lo_irelfn == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL1",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (i1_irelfn == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL2",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (hi_irelfn == irelend || lo_irelfn == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL3",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (hi_irelfn == irelend || lo_irelfn == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP1",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (i2_irelfn == irelend || cond_irelfn == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP2",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (hi_irelfn == irelend || lo_irelfn == irelend || cond_irelfn == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP3",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (hi_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL4",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (ptr_irel == irelend || em_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL4",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
/* Check these is enough space to insert jal in R_NDS32_EMPTY. */
if (cond_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL5",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (em_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGCALL6",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (cond_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd,
- "R_NDS32_LONGCALL6", (long) irel->r_offset);
+ "R_NDS32_LONGCALL6", irel->r_offset);
return FALSE;
}
cond_irel->r_addend = 1;
if (cond_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd,
- "R_NDS32_LONGCALL6", (long) irel->r_offset);
+ "R_NDS32_LONGCALL6", irel->r_offset);
return FALSE;
}
cond_irel->r_addend = 1;
if (hi_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP4",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (ptr_irel == irelend || em_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP4",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (cond_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP5",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (em_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP6",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (cond_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LONGJUMP7",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (hi_irelfn == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_LOADSTORE",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
if (re_irel == irelend)
{
_bfd_error_handler (unrecognized_reloc_msg, abfd, "R_NDS32_PTR",
- (long) irel->r_offset);
+ irel->r_offset);
return FALSE;
}
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_NDS32_PLT_GOTREL_LO19);
/* addi.gp */
- insn = N32_TYPE1 (SBGP, N32_RT5 (insn), __BIT (19));
+ insn = N32_TYPE1 (SBGP, N32_RT5 (insn), N32_BIT (19));
}
else if (N32_OP6 (insn) == N32_OP6_JREG
&& N32_SUB5 (insn) == N32_JREG_JRAL)
ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_SDA18S1_RELA);
break;
case (N32_OP6_MEM << 8) | N32_MEM_LHS:
- insn = N32_TYPE1 (HWGP, N32_RT5 (insn), __BIT (18));
+ insn = N32_TYPE1 (HWGP, N32_RT5 (insn), N32_BIT (18));
irel->r_info =
ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_SDA18S1_RELA);
break;
case (N32_OP6_MEM << 8) | N32_MEM_SH:
- insn = N32_TYPE1 (HWGP, N32_RT5 (insn), __BIT (19));
+ insn = N32_TYPE1 (HWGP, N32_RT5 (insn), N32_BIT (19));
irel->r_info =
ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_SDA18S1_RELA);
break;
ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_SDA19S0_RELA);
break;
case (N32_OP6_MEM << 8) | N32_MEM_LBS:
- insn = N32_TYPE1 (LBGP, N32_RT5 (insn), __BIT (19));
+ insn = N32_TYPE1 (LBGP, N32_RT5 (insn), N32_BIT (19));
irel->r_info =
ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_SDA19S0_RELA);
break;
ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_SDA19S0_RELA);
break;
case (N32_OP6_ALU1 << 8) | N32_ALU1_ADD:
- insn = N32_TYPE1 (SBGP, N32_RT5 (insn), __BIT (19));
+ insn = N32_TYPE1 (SBGP, N32_RT5 (insn), N32_BIT (19));
irel->r_info =
ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_NDS32_SDA19S0_RELA);
break;
of instruction a time.
It recognizes three types of relocations.
- 1. R_NDS32_LABEL - a aligment.
+ 1. R_NDS32_LABEL - a alignment.
2. R_NDS32_INSN16 - relax a 32-bit instruction to 16-bit.
3. is_16bit_NOP () - remove a 16-bit instruction. */
- /* TODO: It seems currently implementation only support 4-byte aligment.
- We should handle any-aligment. */
+ /* TODO: It seems currently implementation only support 4-byte alignment.
+ We should handle any-alignment. */
Elf_Internal_Rela *insn_rel = NULL, *label_rel = NULL, *irel;
Elf_Internal_Rela *tmp_rel, *tmp2_rel = NULL;
* no reloc entry. */
if (bfd_link_relocatable (link_info)
|| (sec->flags & SEC_RELOC) == 0
- || (sec->flags & SEC_EXCLUDE) == 1
+ || (sec->flags & SEC_EXCLUDE) != 0
|| (sec->flags & SEC_CODE) == 0
|| sec->size == 0)
return TRUE;
irelend, isymbuf))
goto error_return;
- if (*again == FALSE)
+ if (!*again)
{
if (!nds32_fag_remove_unused_fpbase (abfd, sec, internal_relocs,
irelend))
nds32_elf_pick_relax (FALSE, sec, again, table, link_info);
- if (*again == FALSE)
+ if (!*again)
{
if (!nds32_relax_adjust_label (abfd, sec, internal_relocs, contents,
&relax_blank_list, optimize, opt_size))
relax_blank_list = NULL;
}
- if (*again == FALSE)
+ if (!*again)
{
/* Closing the section, so we don't relax it anymore. */
bfd_vma sec_size_align;
/* Incorrect alignment. */
_bfd_error_handler
/* xgettext:c-format */
- (_("%s: warning: unaligned small data access. "
- "For entry: {%d, %d, %d}, addr = 0x%x, align = 0x%x."),
- bfd_get_filename (abfd), irel->r_offset,
+ (_("%B: warning: unaligned small data access "
+ "for entry: {%Ld, %Ld, %Ld}, addr = %#Lx, align = %#x"),
+ abfd, irel->r_offset,
irel->r_info, irel->r_addend, relocation, align);
off += 4;
continue;
if (entry == NULL)
{
_bfd_error_handler
- (_("%P%F: failed creating ex9.it %s hash table: %E\n"), code);
+ (_("failed creating ex9.it %s hash table entry"), code);
return FALSE;
}
if (h)
#define elf_backend_size_dynamic_sections nds32_elf_size_dynamic_sections
#define elf_backend_relocate_section nds32_elf_relocate_section
#define elf_backend_gc_mark_hook nds32_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook nds32_elf_gc_sweep_hook
#define elf_backend_grok_prstatus nds32_elf_grok_prstatus
#define elf_backend_grok_psinfo nds32_elf_grok_psinfo
#define elf_backend_reloc_type_class nds32_elf_reloc_type_class