From: Victor Kamensky <victor.kamensky@linaro.org>
To: gdb-patches@sourceware.org
Cc: victor.kamensky@linaro.org
Subject: [PATCH 1/5] ARM: plt_size functions need to read instructions in right byte order
Date: Tue, 21 Oct 2014 00:57:00 -0000 [thread overview]
Message-ID: <1413853021-4393-2-git-send-email-victor.kamensky@linaro.org> (raw)
In-Reply-To: <1413853021-4393-1-git-send-email-victor.kamensky@linaro.org>
elf32_arm_plt0_size and elf32_arm_plt_size read instructions
to determine what is size of PLT entry. However it does not
read instruction correctly in case of ARM big endian V7 case.
In this case instructions are still kept in little endian
order (BE8).
Because of that in armv7b case gdb.base/dprintf-pending.exp
test is failing - It cannot find 'pendfunc@plt' symbol.
And that symbol is not created because elf32_arm_get_synthetic_symtab
function does not create 'pendfunc@plt' symbol for symbols
from PLT after elf32_arm_plt0_size returns -1.
Fix is to introduce code reading functions read_code32,
read_code16 which would read code content in little endian
mode when it is armv7b executabe (i.e e_flags has EF_ARM_BE8)
set. elf32_arm_plt0_size and elf32_arm_plt_size to use these
functions in place where H_GET_32, H_GET_16 were used before.
---
bfd/ChangeLog | 9 +++++++++
bfd/elf32-arm.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e4445dc..8b183ac 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2014-10-13 Victor Kamensky <victor.kamensky@linaro.org>
+
+ * elf32-arm.c (read_code32): New function to read 32 bit
+ arm instruction.
+ (read_code16): New function to read 16 bit thumb instrution.
+ (elf32_arm_plt0_size, elf32_arm_plt_size) change code to use
+ read_code32, read_code16 to read instruction to deal with
+ BE8 arm case.
+
2014-09-29 H.J. Lu <hongjiu.lu@intel.com>
PR ld/17440
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 08aa3f9..89e4f35 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -15953,6 +15953,46 @@ const struct elf_size_info elf32_arm_size_info =
bfd_elf32_swap_reloca_out
};
+static bfd_vma
+read_code32 (const bfd *abfd, const bfd_byte *addr)
+{
+ bfd_vma retval;
+
+ if ((elf_elfheader(abfd)->e_flags) & EF_ARM_BE8)
+ {
+ /*
+ * V7 BE8 code is always little endian
+ */
+ retval = bfd_getl32(addr);
+ }
+ else
+ {
+ retval = H_GET_32(abfd, addr);
+ }
+ return retval;
+}
+
+
+static bfd_vma
+read_code16 (const bfd *abfd, const bfd_byte *addr)
+{
+ bfd_vma retval;
+
+ if ((elf_elfheader(abfd)->e_flags) & EF_ARM_BE8)
+ {
+ /*
+ * V7 BE8 code is always little endian
+ */
+ retval = bfd_getl16(addr);
+ }
+ else
+ {
+ retval = H_GET_16(abfd, addr);
+ }
+ return retval;
+}
+
+
/* Return size of plt0 entry starting at ADDR
or (bfd_vma) -1 if size can not be determined. */
@@ -15962,7 +16002,7 @@ elf32_arm_plt0_size (const bfd *abfd, const bfd_byte *addr)
bfd_vma first_word;
bfd_vma plt0_size;
- first_word = H_GET_32 (abfd, addr);
+ first_word = read_code32 (abfd, addr);
if (first_word == elf32_arm_plt0_entry[0])
plt0_size = 4 * ARRAY_SIZE (elf32_arm_plt0_entry);
@@ -15987,17 +16027,17 @@ elf32_arm_plt_size (const bfd *abfd, const bfd_byte *start, bfd_vma offset)
const bfd_byte *addr = start + offset;
/* PLT entry size if fixed on Thumb-only platforms. */
- if (H_GET_32(abfd, start) == elf32_thumb2_plt0_entry[0])
+ if (read_code32(abfd, start) == elf32_thumb2_plt0_entry[0])
return 4 * ARRAY_SIZE (elf32_thumb2_plt_entry);
/* Respect Thumb stub if necessary. */
- if (H_GET_16(abfd, addr) == elf32_arm_plt_thumb_stub[0])
+ if (read_code16(abfd, addr) == elf32_arm_plt_thumb_stub[0])
{
plt_size += 2 * ARRAY_SIZE(elf32_arm_plt_thumb_stub);
}
/* Strip immediate from first add. */
- first_insn = H_GET_32(abfd, addr + plt_size) & 0xffffff00;
+ first_insn = read_code32(abfd, addr + plt_size) & 0xffffff00;
#ifdef FOUR_WORD_PLT
if (first_insn == elf32_arm_plt_entry[0])
--
1.8.1.4
next prev parent reply other threads:[~2014-10-21 0:57 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 0:57 [PATCH 0/5] arm: set of big endian related fixes for armeb (v7) Victor Kamensky
2014-10-21 0:57 ` [PATCH 4/5] ARM: read_pieced_value do big endian processing only in case of valid gdb_regnum Victor Kamensky
2014-10-22 9:31 ` Yao Qi
2014-10-22 15:27 ` Victor Kamensky
2014-10-23 3:22 ` Yao Qi
2014-10-23 5:43 ` Victor Kamensky
2014-10-23 6:24 ` Yao Qi
2014-10-21 0:57 ` [PATCH 5/5] ARM: asm-source.exp link options in case of armv7b target Victor Kamensky
2014-10-24 6:10 ` Yao Qi
2014-10-24 6:35 ` Victor Kamensky
2014-10-24 6:38 ` Andrew Pinski
2014-10-24 8:57 ` Yao Qi
2014-10-24 17:11 ` Victor Kamensky
2014-10-21 0:57 ` Victor Kamensky [this message]
2014-10-21 0:57 ` [PATCH 3/5] ARM: arm_breakpoint should be little endian form in case for arm BE8 Victor Kamensky
2014-10-21 8:13 ` Yao Qi
2014-10-21 0:57 ` [PATCH 2/5] ARM: extract_arm_insn function need to read instrs correctly in be8 case Victor Kamensky
2014-10-21 7:58 ` Yao Qi
2014-10-21 8:04 ` Yao Qi
2014-10-21 14:45 ` Victor Kamensky
2014-10-24 12:20 ` gdb/CONTRIBUTE Pedro Alves
2014-10-24 17:36 ` gdb/CONTRIBUTE Victor Kamensky
2014-10-21 1:12 ` [PATCH 0/5] arm: set of big endian related fixes for armeb (v7) Andrew Pinski
2014-10-21 5:22 ` Victor Kamensky
2014-10-21 7:39 ` Yao Qi
2014-10-22 5:39 ` Victor Kamensky
2014-10-22 9:36 ` Yao Qi
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=1413853021-4393-2-git-send-email-victor.kamensky@linaro.org \
--to=victor.kamensky@linaro.org \
--cc=gdb-patches@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