On 7/17/23 22:21, Michael Tokarev wrote:
17.07.2023 22:58, Helge Deller wrote:
This patch seems to work. Tested with qemu-arm and qemu-amd64.

Wow!

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index a26200d9f3..b583018591 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -3615,6 +3631,13 @@ int load_elf_binary(struct linux_binprm *bprm, struct 
image_info *info)

      if (elf_interpreter) {
          load_elf_interp(elf_interpreter, &interp_info, bprm->buf);
+        /*
+         * adjust brk address if the interpreter was loaded above the main
+         * executable, e.g. happens with static binaries on armhf

Guess you mean dynamic binaries?  the klibc binaries we used are dynamic, no?

Well, it's a static binary, but with dynamic interpreter:

deller@abel:~$ file fstype
fstype: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically 
linked, interpreter /lib/klibc-m13AniKHUCMUNN8mXSUhIi8CUSA.so, 
BuildID[sha1]=127738bcbae6cad12468cc4182c9b289c3452864, stripped

+         */
+        if (interp_info.brk > info->brk) {
+            info->brk = interp_info.brk;
+        }

Heh.  So it clashes with brk. Nice... ;)

You should ping upstream about this one before 8.1 is out, I think.

I've queued up quite some other brk() fixes here:
https://github.com/hdeller/qemu-hppa/tree/upx-strace-fix-2
They hopefully fix all remaining issues.

Helge

Reply via email to