[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory
From: |
Helge Deller |
Subject: |
Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory |
Date: |
Wed, 2 Aug 2023 21:57:55 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
On 8/2/23 20:36, Richard Henderson wrote:
On 8/1/23 16:27, Helge Deller wrote:
+/* where to map binaries? */
+#if HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
+# define TASK_UNMAPPED_BASE_PIE 0x5500000000
+# define TASK_UNMAPPED_BASE 0x7000000000
+#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 32
+# define TASK_UNMAPPED_BASE_PIE 0x00300000
+# define TASK_UNMAPPED_BASE (GUEST_ADDR_MAX - 0x20000000 + 1)
+#else /* HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 32 */
+# define TASK_UNMAPPED_BASE_PIE 0x00000000
+# define TASK_UNMAPPED_BASE 0x40000000
+#endif
It would probably be easier to follow if you use the kernel's name:
ELF_ET_DYN_BASE.
Agreed.
Should be in linux-user/$GUEST/target_mmap.h with
TASK_UNMAPPED_BASE, per my comment vs patch 7.
Maybe, but see my comments/answers there...
+ /* do sanity checks on guest memory layout */
+ if (mmap_next_start >= GUEST_ADDR_MAX) {
+ mmap_next_start = GUEST_ADDR_MAX - 0x1000000000 + 1;
+ }
What in the world is that random number?
It's random. Idea is to keep enough space for shared libs below GUEST_ADDR_MAX.
It certainly won't compile
on 32-bit host, and certainly isn't relevant to a 32-bit guest.
That code will never be compiled/executed on 32-bit guests & hosts.
The defines for TASK_UNMAPPED_BASE take already care of that.
But I agree it's not directly visible (and probably not nice that way).
+ if (TASK_UNMAPPED_BASE_PIE >= mmap_next_start) {
+ fprintf(stderr, "Memory too small for PIE executables.\n");
+ exit(EXIT_FAILURE);
+ }
Really bad timing for this diagnostic. What if a PIE executable isn't even
being used?
Both TASK_UNMAPPED_BASE and ELF_ET_DYN_BASE could be computed in main (or a
subroutine), when reserved_va is assigned.
Helge
- Re: [PATCH v6 7/8] linux-user: Optimize memory layout for static and dynamic executables, (continued)
[PATCH v6 8/8] linux-user: Load pie executables at upper memory, Helge Deller, 2023/08/01
- Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory, Akihiko Odaki, 2023/08/02
- Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory, Helge Deller, 2023/08/02
- Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory, Akihiko Odaki, 2023/08/02
- Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory, Helge Deller, 2023/08/02
- Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory, Akihiko Odaki, 2023/08/02
- Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory, Helge Deller, 2023/08/02
Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory, Richard Henderson, 2023/08/02
- Re: [PATCH v6 8/8] linux-user: Load pie executables at upper memory,
Helge Deller <=
[PATCH v6 6/8] linux-user: Show heap address in /proc/pid/maps, Helge Deller, 2023/08/01
[PATCH v6 3/8] linux-user: Use MAP_FIXED_NOREPLACE for do_brk(), Helge Deller, 2023/08/01
Re: [PATCH v6 0/8] linux-user: brk fixes, Joel Stanley, 2023/08/01