aboutsummaryrefslogtreecommitdiff
path: root/linux-user/elfload.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-09-28 11:22:36 +0100
committerPeter Maydell <peter.maydell@linaro.org>2018-09-28 11:22:36 +0100
commitaa8e26de9617756febcbf794dda965df307fdaaa (patch)
treec6c20e338e1323c2f374686975b6c2390a1411a6 /linux-user/elfload.c
parent866ba8385466a1a74ea4729e2a247c4c75584166 (diff)
parent5dfa88f7162f390463b227940e84a23af5407744 (diff)
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.1-pull-request' into staging
- some fixes for setrlimit() and write() - fixes ELF loader when host page size is greater than target page size - add SO_LINGER to getsockopt()/setsockopt() - move TargetFdTrans from syscall.c v2: add "#include <linux/netlink.h>" in linux-user/fd-trans.c # gpg: Signature made Tue 25 Sep 2018 21:51:13 BST # gpg: using RSA key F30C38BD3F2FBE3C # gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" # gpg: aka "Laurent Vivier <laurent@vivier.eu>" # gpg: aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" # Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F 5173 F30C 38BD 3F2F BE3C * remotes/vivier2/tags/linux-user-for-3.1-pull-request: linux-user: do setrlimit selectively linux-user: write(fd, NULL, 0) parity with linux's treatment of same linux-user: elf: mmap all the target-pages of hostpage for data segment linux-user: add SO_LINGER to {g,s}etsockopt linux-user: move TargetFdTrans functions to their own file Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r--linux-user/elfload.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index e97c4cde49..10bca65b99 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1439,7 +1439,10 @@ struct exec
#define QMAGIC 0314
/* Necessary parameters */
-#define TARGET_ELF_EXEC_PAGESIZE TARGET_PAGE_SIZE
+#define TARGET_ELF_EXEC_PAGESIZE \
+ (((eppnt->p_align & ~qemu_host_page_mask) != 0) ? \
+ TARGET_PAGE_SIZE : MAX(qemu_host_page_size, TARGET_PAGE_SIZE))
+#define TARGET_ELF_PAGELENGTH(_v) ROUND_UP((_v), TARGET_ELF_EXEC_PAGESIZE)
#define TARGET_ELF_PAGESTART(_v) ((_v) & \
~(abi_ulong)(TARGET_ELF_EXEC_PAGESIZE-1))
#define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1))
@@ -2281,7 +2284,7 @@ static void load_elf_image(const char *image_name, int image_fd,
for (i = 0; i < ehdr->e_phnum; i++) {
struct elf_phdr *eppnt = phdr + i;
if (eppnt->p_type == PT_LOAD) {
- abi_ulong vaddr, vaddr_po, vaddr_ps, vaddr_ef, vaddr_em;
+ abi_ulong vaddr, vaddr_po, vaddr_ps, vaddr_ef, vaddr_em, vaddr_len;
int elf_prot = 0;
if (eppnt->p_flags & PF_R) elf_prot = PROT_READ;
@@ -2291,8 +2294,9 @@ static void load_elf_image(const char *image_name, int image_fd,
vaddr = load_bias + eppnt->p_vaddr;
vaddr_po = TARGET_ELF_PAGEOFFSET(vaddr);
vaddr_ps = TARGET_ELF_PAGESTART(vaddr);
+ vaddr_len = TARGET_ELF_PAGELENGTH(eppnt->p_filesz + vaddr_po);
- error = target_mmap(vaddr_ps, eppnt->p_filesz + vaddr_po,
+ error = target_mmap(vaddr_ps, vaddr_len,
elf_prot, MAP_PRIVATE | MAP_FIXED,
image_fd, eppnt->p_offset - vaddr_po);
if (error == -1) {