From: Kai Backman <kaib@google.com>
To: Riku Voipio <riku.voipio@iki.fi>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Patch to fix mapping of elf pheaders specifying both .data and .bss segments
Date: Thu, 6 Aug 2009 15:41:02 -0700 [thread overview]
Message-ID: <c7187c3d0908061541o539e0e16ka87ebbc58f7cd873@mail.gmail.com> (raw)
In-Reply-To: <20090618185731.GC24046@kos.to>
[-- Attachment #1: Type: text/plain, Size: 300 bytes --]
On Thu, Jun 18, 2009 at 11:57 AM, Riku Voipio<riku.voipio@iki.fi> wrote:
> The patch attached is totally messed up thou.
Sorry for the delay. I was vacationing in Finland (incidentally)..
To restart the thread, I've re-attached the patch.
Kai
--
Kai Backman, Software Engineer, kaib@google.com
[-- Attachment #2: qemu_bss.patch --]
[-- Type: text/x-diff, Size: 1719 bytes --]
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 190ad14..e4e75d5 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1211,7 +1211,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
abi_ulong mapped_addr;
struct elf_phdr * elf_ppnt;
struct elf_phdr *elf_phdata;
- abi_ulong elf_bss, k, elf_brk;
+ abi_ulong elf_bss, last_bss, mapped_bss, k, elf_brk;
int retval;
char * elf_interpreter;
abi_ulong elf_entry, interp_load_addr = 0;
@@ -1271,6 +1271,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
elf_ppnt = elf_phdata;
elf_bss = 0;
+ last_bss = 0;
elf_brk = 0;
@@ -1495,12 +1496,24 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz;
if (k > elf_bss)
elf_bss = k;
+ k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz;
+ if (k > last_bss)
+ last_bss = k;
if ((elf_ppnt->p_flags & PF_X) && end_code < k)
end_code = k;
if (end_data < k)
end_data = k;
k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz;
if (k > elf_brk) elf_brk = k;
+ if (!elf_interpreter && last_bss > elf_bss) {
+ padzero(elf_bss, last_bss);
+ mapped_bss = TARGET_ELF_PAGESTART(elf_bss + qemu_host_page_size - 1);
+
+ /* Map the last of the bss segment */
+ target_mmap(load_bias + mapped_bss, last_bss-mapped_bss,
+ PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+ }
}
elf_entry += load_bias;
next prev parent reply other threads:[~2009-08-06 22:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-17 17:36 [Qemu-devel] Patch to fix mapping of elf pheaders specifying both .data and .bss segments Kai Backman
2009-06-18 18:57 ` Riku Voipio
2009-08-06 22:41 ` Kai Backman [this message]
2009-08-12 15:06 ` Riku Voipio
2009-08-28 20:10 ` Max Filippov
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=c7187c3d0908061541o539e0e16ka87ebbc58f7cd873@mail.gmail.com \
--to=kaib@google.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).