qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Markovic <stefan.markovic@rt-rk.com>
To: qemu-devel@nongnu.org
Cc: aurelien@aurel32.net, amarkovic@wavecomp.com,
	pjovanovic@wavecomp.com, riku.voipio@iki.fi, laurent@vivier.eu
Subject: [Qemu-devel] [PATCH 3/6] Extract MIPS abiflags from ELF file
Date: Fri, 26 Oct 2018 16:21:04 +0200	[thread overview]
Message-ID: <1540563667-23300-4-git-send-email-stefan.markovic@rt-rk.com> (raw)
In-Reply-To: <1540563667-23300-1-git-send-email-stefan.markovic@rt-rk.com>

From: Stefan Markovic <smarkovic@wavecomp.com>

Signed-off-by: Stefan Markovic <smarkovic@wavecomp.com>
---
 linux-user/elfload.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 055f6a9..5881233 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1517,11 +1517,25 @@ static void bswap_sym(struct elf_sym *sym)
     bswaptls(&sym->st_size);
     bswap16s(&sym->st_shndx);
 }
+
+#ifdef TARGET_MIPS
+static void bswap_mips_abiflags(Mips_elf_abiflags_v0 *abiflags)
+{
+    bswap16s(&abiflags->version);
+    bswap32s(&abiflags->ases);
+    bswap32s(&abiflags->isa_ext);
+    bswap32s(&abiflags->flags1);
+    bswap32s(&abiflags->flags2);
+}
+#endif
 #else
 static inline void bswap_ehdr(struct elfhdr *ehdr) { }
 static inline void bswap_phdr(struct elf_phdr *phdr, int phnum) { }
 static inline void bswap_shdr(struct elf_shdr *shdr, int shnum) { }
 static inline void bswap_sym(struct elf_sym *sym) { }
+#ifdef TARGET_MIPS
+static inline void bswap_mips_abiflags(Mips_elf_abiflags_v0 *abiflags) { }
+#endif
 #endif
 
 #ifdef USE_ELF_CORE_DUMP
@@ -2364,6 +2378,25 @@ static void load_elf_image(const char *image_name, int image_fd,
                 goto exit_errmsg;
             }
             *pinterp_name = interp_name;
+#ifdef TARGET_MIPS
+        } else if (eppnt->p_type == PT_MIPS_ABIFLAGS) {
+            Mips_elf_abiflags_v0 abiflags;
+            if (eppnt->p_filesz < sizeof(Mips_elf_abiflags_v0)) {
+                errmsg = "Invalid PT_MIPS_ABIFLAGS entry";
+                goto exit_errmsg;
+            }
+            if (eppnt->p_offset + eppnt->p_filesz <= BPRM_BUF_SIZE) {
+                memcpy(&abiflags, bprm_buf + eppnt->p_offset,
+                       sizeof(Mips_elf_abiflags_v0));
+            } else {
+                retval = pread(image_fd, &abiflags, sizeof(Mips_elf_abiflags_v0),
+                               eppnt->p_offset);
+                if (retval != sizeof(Mips_elf_abiflags_v0)) {
+                    goto exit_perror;
+                }
+            }
+            bswap_mips_abiflags(&abiflags);
+#endif
         }
     }
 
-- 
1.9.1

  parent reply	other threads:[~2018-10-26 14:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 14:21 [Qemu-devel] [PATCH 0/6] target/mips: Add support for prctl() PR_GET_FP_MODE and PR_SET_FP_MODE Stefan Markovic
2018-10-26 14:21 ` [Qemu-devel] [PATCH 1/6] Define MIPS_ABI_FP_UNKNOWN macro Stefan Markovic
2018-10-26 16:12   ` Aleksandar Markovic
2018-10-26 14:21 ` [Qemu-devel] [PATCH 2/6] Extend image_info struct with MIPS specific fp_abi and interp_fp_abi fields Stefan Markovic
2018-10-26 16:10   ` Aleksandar Markovic
2018-10-26 14:21 ` Stefan Markovic [this message]
2018-10-26 16:09   ` [Qemu-devel] [PATCH 3/6] Extract MIPS abiflags from ELF file Aleksandar Markovic
2018-10-26 14:21 ` [Qemu-devel] [PATCH 4/6] Read and set FP ABI value from MIPS abiflags Stefan Markovic
2018-10-26 16:07   ` Aleksandar Markovic
2018-10-26 14:21 ` [Qemu-devel] [PATCH 5/6] Determine the desired FPU mode Stefan Markovic
2018-10-26 16:06   ` Aleksandar Markovic
2018-10-26 18:12   ` Peter Maydell
2018-10-26 19:10     ` Aleksandar Markovic
2018-10-29 13:15     ` [Qemu-devel] ?==?utf-8?q? ?==?utf-8?q? " Stefan Markovic
2018-10-26 14:21 ` [Qemu-devel] [PATCH 6/6] Add prctl() PR_SET_FP_MODE and PR_GET_FP_MODE implementations Stefan Markovic
2018-10-26 16:05   ` Aleksandar Markovic
2018-10-26 17:06 ` [Qemu-devel] [PATCH 0/6] target/mips: Add support for prctl() PR_GET_FP_MODE and PR_SET_FP_MODE Aleksandar Markovic

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=1540563667-23300-4-git-send-email-stefan.markovic@rt-rk.com \
    --to=stefan.markovic@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=aurelien@aurel32.net \
    --cc=laurent@vivier.eu \
    --cc=pjovanovic@wavecomp.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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 NNTP newsgroup(s).