From: Cupertino Miranda <Cupertino.Miranda@synopsys.com>
To: "binutils@sourceware.org" <binutils@sourceware.org>
Cc: Claudiu Zissulescu <Claudiu.Zissulescu@synopsys.com>
Subject: [PATCH ARC 1/5]: Dynamic relocs verification for dynindx == -1
Date: Mon, 04 Apr 2016 12:49:00 -0000 [thread overview]
Message-ID: <EB86EB452ADE4B44B294F7149B8A2777021A5DE2@DE02WEMBXB.internal.synopsys.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 522 bytes --]
Hi all,
Please review.
This patch strengths verification that no dynamic relocation is
generated with an invalid symbol.
Best regards,
Cupertino
bfd/ChangeLog:
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-DynSymIssue.patch --]
[-- Type: text/x-patch; name="0001-DynSymIssue.patch", Size: 2680 bytes --]
From a14d7db2d222b58eb37b670026a9ac83934033d2 Mon Sep 17 00:00:00 2001
From: Cupertino Miranda <Cupertino.Miranda@synopsys.com>
Date: Tue, 8 Mar 2016 15:08:48 +0100
Subject: [PATCH 1/7] STAR 9001011480: Dynamic reloc symbols issue.
Dynamic reloc symbols were set with index -1.
---
bfd/elf32-arc.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index 488b86f..e9fda51 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -64,6 +64,7 @@ name_for_global_symbol (struct elf_link_hash_entry *h)
_rel.r_addend = ADDEND; \
_rel.r_offset = (_htab->s##SECTION)->output_section->vma \
+ (_htab->s##SECTION)->output_offset + OFFSET; \
+ BFD_ASSERT (SYM_IDX != -1); \
_rel.r_info = ELF32_R_INFO (SYM_IDX, TYPE); \
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
|| r_type == R_ARC_32_PCREL)
{
- BFD_ASSERT (h != NULL && h->dynindx != -1);
+ BFD_ASSERT (h != NULL);
if ((input_section->flags & SEC_ALLOC) != 0)
relocate = FALSE;
else
relocate = TRUE;
+
+ BFD_ASSERT (h->dynindx != -1);
outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
}
else
@@ -1535,6 +1538,8 @@ elf_arc_relocate_section (bfd * output_bfd,
relocate = FALSE;
else
relocate = TRUE;
+
+ BFD_ASSERT (h->dynindx != -1);
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
+ got_offset);
rel.r_addend = 0;
+
+ BFD_ASSERT (h->dynindx != -1);
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARC_JMP_SLOT);
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);
}
- 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,
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;
rel.r_addend = 0;
rel.r_offset = rel_offset;
+
+ BFD_ASSERT (h->dynindx != -1);
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARC_COPY);
bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
--
1.9.1
next reply other threads:[~2016-04-04 12:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-04 12:49 Cupertino Miranda [this message]
2016-04-05 14:28 ` Nick Clifton
2016-04-05 14:51 ` Claudiu Zissulescu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=EB86EB452ADE4B44B294F7149B8A2777021A5DE2@DE02WEMBXB.internal.synopsys.com \
--to=cupertino.miranda@synopsys.com \
--cc=Claudiu.Zissulescu@synopsys.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).