summaryrefslogtreecommitdiffstats
path: root/linux-user
diff options
context:
space:
mode:
authorJiaxun Yang2022-08-03 12:30:08 +0200
committerLaurent Vivier2022-09-27 13:19:05 +0200
commitfcdc0ab4b4d09bac65c192726af1c1bcb28de8e4 (patch)
tree4da861c894add053f19a4d1fd41a9d8a99313576 /linux-user
parentlinux-user/s390x: Save/restore fpc when handling a signal (diff)
downloadqemu-fcdc0ab4b4d09bac65c192726af1c1bcb28de8e4.tar.gz
qemu-fcdc0ab4b4d09bac65c192726af1c1bcb28de8e4.tar.xz
qemu-fcdc0ab4b4d09bac65c192726af1c1bcb28de8e4.zip
linux-user: Introduce stubs for ELF AT_BASE_PLATFORM
AT_BASE_PLATFORM is a elf auxiliary vector pointing to a string to pass some architecture information. See getauxval(3) man-page. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220803103009.95972-2-jiaxun.yang@flygoat.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index c7e3f1d47c..581fbc858b 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1776,6 +1776,10 @@ static inline void init_thread(struct target_pt_regs *regs,
#endif /* TARGET_HEXAGON */
+#ifndef ELF_BASE_PLATFORM
+#define ELF_BASE_PLATFORM (NULL)
+#endif
+
#ifndef ELF_PLATFORM
#define ELF_PLATFORM (NULL)
#endif
@@ -2220,8 +2224,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
int i;
abi_ulong u_rand_bytes;
uint8_t k_rand_bytes[16];
- abi_ulong u_platform;
- const char *k_platform;
+ abi_ulong u_platform, u_base_platform;
+ const char *k_platform, *k_base_platform;
const int n = sizeof(elf_addr_t);
sp = p;
@@ -2243,6 +2247,22 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
}
}
+ u_base_platform = 0;
+ k_base_platform = ELF_BASE_PLATFORM;
+ if (k_base_platform) {
+ size_t len = strlen(k_base_platform) + 1;
+ if (STACK_GROWS_DOWN) {
+ sp -= (len + n - 1) & ~(n - 1);
+ u_base_platform = sp;
+ /* FIXME - check return value of memcpy_to_target() for failure */
+ memcpy_to_target(sp, k_base_platform, len);
+ } else {
+ memcpy_to_target(sp, k_base_platform, len);
+ u_base_platform = sp;
+ sp += len + 1;
+ }
+ }
+
u_platform = 0;
k_platform = ELF_PLATFORM;
if (k_platform) {
@@ -2284,6 +2304,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
}
size = (DLINFO_ITEMS + 1) * 2;
+ if (k_base_platform)
+ size += 2;
if (k_platform)
size += 2;
#ifdef DLINFO_ARCH_ITEMS
@@ -2361,6 +2383,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
NEW_AUX_ENT(AT_HWCAP2, (abi_ulong) ELF_HWCAP2);
#endif
+ if (u_base_platform) {
+ NEW_AUX_ENT(AT_BASE_PLATFORM, u_base_platform);
+ }
if (u_platform) {
NEW_AUX_ENT(AT_PLATFORM, u_platform);
}