* [PATCH] linux-user: add support for xtensa FDPIC
@ 2023-02-05 6:12 Max Filippov
2023-03-07 10:57 ` Laurent Vivier
0 siblings, 1 reply; 2+ messages in thread
From: Max Filippov @ 2023-02-05 6:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Max Filippov
Define xtensa-specific info_is_fdpic and fill in FDPIC-specific
registers in the xtensa version of init_thread.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
include/elf.h | 1 +
linux-user/elfload.c | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/elf.h b/include/elf.h
index 8bf1e72720d5..e8bfe38a9fbd 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -1619,6 +1619,7 @@ typedef struct elf64_shdr {
#define ELFOSABI_MODESTO 11 /* Novell Modesto. */
#define ELFOSABI_OPENBSD 12 /* OpenBSD. */
#define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC */
+#define ELFOSABI_XTENSA_FDPIC 65 /* Xtensa FDPIC */
#define ELFOSABI_ARM 97 /* ARM */
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 5928c14dfc97..150d1d450396 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1748,6 +1748,15 @@ static inline void init_thread(struct target_pt_regs *regs,
regs->windowstart = 1;
regs->areg[1] = infop->start_stack;
regs->pc = infop->entry;
+ if (info_is_fdpic(infop)) {
+ regs->areg[4] = infop->loadmap_addr;
+ regs->areg[5] = infop->interpreter_loadmap_addr;
+ if (infop->interpreter_loadmap_addr) {
+ regs->areg[6] = infop->interpreter_pt_dynamic_addr;
+ } else {
+ regs->areg[6] = infop->pt_dynamic_addr;
+ }
+ }
}
/* See linux kernel: arch/xtensa/include/asm/elf.h. */
@@ -2207,11 +2216,16 @@ static void zero_bss(abi_ulong elf_bss, abi_ulong last_bss, int prot)
}
}
-#ifdef TARGET_ARM
+#if defined(TARGET_ARM)
static int elf_is_fdpic(struct elfhdr *exec)
{
return exec->e_ident[EI_OSABI] == ELFOSABI_ARM_FDPIC;
}
+#elif defined(TARGET_XTENSA)
+static int elf_is_fdpic(struct elfhdr *exec)
+{
+ return exec->e_ident[EI_OSABI] == ELFOSABI_XTENSA_FDPIC;
+}
#else
/* Default implementation, always false. */
static int elf_is_fdpic(struct elfhdr *exec)
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] linux-user: add support for xtensa FDPIC
2023-02-05 6:12 [PATCH] linux-user: add support for xtensa FDPIC Max Filippov
@ 2023-03-07 10:57 ` Laurent Vivier
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2023-03-07 10:57 UTC (permalink / raw)
To: Max Filippov, qemu-devel
Le 05/02/2023 à 07:12, Max Filippov a écrit :
> Define xtensa-specific info_is_fdpic and fill in FDPIC-specific
> registers in the xtensa version of init_thread.
>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
> include/elf.h | 1 +
> linux-user/elfload.c | 16 +++++++++++++++-
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/include/elf.h b/include/elf.h
> index 8bf1e72720d5..e8bfe38a9fbd 100644
> --- a/include/elf.h
> +++ b/include/elf.h
> @@ -1619,6 +1619,7 @@ typedef struct elf64_shdr {
> #define ELFOSABI_MODESTO 11 /* Novell Modesto. */
> #define ELFOSABI_OPENBSD 12 /* OpenBSD. */
> #define ELFOSABI_ARM_FDPIC 65 /* ARM FDPIC */
> +#define ELFOSABI_XTENSA_FDPIC 65 /* Xtensa FDPIC */
> #define ELFOSABI_ARM 97 /* ARM */
> #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 5928c14dfc97..150d1d450396 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -1748,6 +1748,15 @@ static inline void init_thread(struct target_pt_regs *regs,
> regs->windowstart = 1;
> regs->areg[1] = infop->start_stack;
> regs->pc = infop->entry;
> + if (info_is_fdpic(infop)) {
> + regs->areg[4] = infop->loadmap_addr;
> + regs->areg[5] = infop->interpreter_loadmap_addr;
> + if (infop->interpreter_loadmap_addr) {
> + regs->areg[6] = infop->interpreter_pt_dynamic_addr;
> + } else {
> + regs->areg[6] = infop->pt_dynamic_addr;
> + }
> + }
> }
>
> /* See linux kernel: arch/xtensa/include/asm/elf.h. */
> @@ -2207,11 +2216,16 @@ static void zero_bss(abi_ulong elf_bss, abi_ulong last_bss, int prot)
> }
> }
>
> -#ifdef TARGET_ARM
> +#if defined(TARGET_ARM)
> static int elf_is_fdpic(struct elfhdr *exec)
> {
> return exec->e_ident[EI_OSABI] == ELFOSABI_ARM_FDPIC;
> }
> +#elif defined(TARGET_XTENSA)
> +static int elf_is_fdpic(struct elfhdr *exec)
> +{
> + return exec->e_ident[EI_OSABI] == ELFOSABI_XTENSA_FDPIC;
> +}
> #else
> /* Default implementation, always false. */
> static int elf_is_fdpic(struct elfhdr *exec)
Applied to my linux-user-for-8.0 branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-07 10:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-05 6:12 [PATCH] linux-user: add support for xtensa FDPIC Max Filippov
2023-03-07 10:57 ` Laurent Vivier
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).