[ARC] Dynamic relocs verification for dynindx == -1.

bfd/
2016-04-05  Cupertino Miranda  <cmiranda@synopsys.com>

	* elf32-arc.c (name_for_global_symbol): Added assert to check for
	symbol index.
	(elf_arc_relocate_section): Added and changed asserts, validating
	the synamic symbol index.
	(elf_arc_finish_dynamic_symbol): Do not fill the dynamic
	relocation if symbol has dynindx set to -1.
This commit is contained in:
Claudiu Zissulescu 2016-04-05 16:34:12 +02:00
parent 6ec1f28285
commit 94e5c97160
2 changed files with 23 additions and 2 deletions

View file

@ -1,3 +1,12 @@
2016-04-05 Cupertino Miranda <cmiranda@synopsys.com>
* elf32-arc.c (name_for_global_symbol): Added assert to check for
symbol index.
(elf_arc_relocate_section): Added and changed asserts, validating
the synamic symbol index.
(elf_arc_finish_dynamic_symbol): Do not fill the dynamic
relocation if symbol has dynindx set to -1.
2016-04-05 Maciej W. Rozycki <macro@imgtec.com> 2016-04-05 Maciej W. Rozycki <macro@imgtec.com>
* elflink.c (elf_link_add_object_symbols): Always turn hidden * elflink.c (elf_link_add_object_symbols): Always turn hidden

View file

@ -64,6 +64,7 @@ name_for_global_symbol (struct elf_link_hash_entry *h)
_rel.r_addend = ADDEND; \ _rel.r_addend = ADDEND; \
_rel.r_offset = (_htab->s##SECTION)->output_section->vma \ _rel.r_offset = (_htab->s##SECTION)->output_section->vma \
+ (_htab->s##SECTION)->output_offset + OFFSET; \ + (_htab->s##SECTION)->output_offset + OFFSET; \
BFD_ASSERT ((long) SYM_IDX != -1); \
_rel.r_info = ELF32_R_INFO (SYM_IDX, TYPE); \ _rel.r_info = ELF32_R_INFO (SYM_IDX, TYPE); \
bfd_elf32_swap_reloca_out (BFD, &_rel, _loc); \ bfd_elf32_swap_reloca_out (BFD, &_rel, _loc); \
} }
@ -1495,11 +1496,13 @@ elf_arc_relocate_section (bfd * output_bfd,
else if (r_type == R_ARC_PC32 else if (r_type == R_ARC_PC32
|| r_type == R_ARC_32_PCREL) || r_type == R_ARC_32_PCREL)
{ {
BFD_ASSERT (h != NULL && h->dynindx != -1); BFD_ASSERT (h != NULL);
if ((input_section->flags & SEC_ALLOC) != 0) if ((input_section->flags & SEC_ALLOC) != 0)
relocate = FALSE; relocate = FALSE;
else else
relocate = TRUE; relocate = TRUE;
BFD_ASSERT (h->dynindx != -1);
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
} }
else else
@ -1535,6 +1538,8 @@ elf_arc_relocate_section (bfd * output_bfd,
relocate = FALSE; relocate = FALSE;
else else
relocate = TRUE; relocate = TRUE;
BFD_ASSERT (h->dynindx != -1);
outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARC_32); outrel.r_info = ELF32_R_INFO (h->dynindx, R_ARC_32);
} }
} }
@ -2001,6 +2006,8 @@ GOT_ENTRY_OFFSET = 0x%x, GOT_ENTRY_VMA = 0x%x, for symbol %s\n",
+ htab->sgotplt->output_offset + htab->sgotplt->output_offset
+ got_offset); + got_offset);
rel.r_addend = 0; rel.r_addend = 0;
BFD_ASSERT (h->dynindx != -1);
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARC_JMP_SLOT); rel.r_info = ELF32_R_INFO (h->dynindx, R_ARC_JMP_SLOT);
loc = htab->srelplt->contents; loc = htab->srelplt->contents;
@ -2199,7 +2206,10 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd,
{ {
ADD_RELA (output_bfd, got, got_offset, 0, R_ARC_RELATIVE, 0); ADD_RELA (output_bfd, got, got_offset, 0, R_ARC_RELATIVE, 0);
} }
else /* Do not fully understand the side effects of this condition.
The relocation space might still being reserved. Perhaps
I should clear its value. */
else if (h->dynindx != -1)
{ {
ADD_RELA (output_bfd, got, got_offset, h->dynindx, ADD_RELA (output_bfd, got, got_offset, h->dynindx,
R_ARC_GLOB_DAT, 0); R_ARC_GLOB_DAT, 0);
@ -2274,6 +2284,8 @@ GOT_OFFSET = 0x%x, GOT_VMA = 0x%x, INDEX = %d, ADDEND = 0x%x\n",
Elf_Internal_Rela rel; Elf_Internal_Rela rel;
rel.r_addend = 0; rel.r_addend = 0;
rel.r_offset = rel_offset; rel.r_offset = rel_offset;
BFD_ASSERT (h->dynindx != -1);
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARC_COPY); rel.r_info = ELF32_R_INFO (h->dynindx, R_ARC_COPY);
bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);