[PATCH v3 00/87] linux-user: Split up elfload.c

Richard Henderson posted 87 patches 1 month ago
Failed in applying to current master (apply log)
linux-user/aarch64/target_elf.h         |  21 +
linux-user/aarch64/target_ptrace.h      |  14 +
linux-user/aarch64/target_syscall.h     |   7 -
linux-user/alpha/target_elf.h           |   3 +
linux-user/alpha/target_syscall.h       |  40 --
linux-user/arm/target_elf.h             |  18 +
linux-user/arm/target_ptrace.h          |  16 +
linux-user/arm/target_syscall.h         |   8 -
linux-user/hexagon/target_elf.h         |   3 +
linux-user/hexagon/target_syscall.h     |   5 -
linux-user/hppa/target_elf.h            |   8 +
linux-user/hppa/target_syscall.h        |  18 -
linux-user/i386/target_elf.h            |  34 +
linux-user/i386/target_ptrace.h         |  31 +
linux-user/i386/target_syscall.h        |  18 -
linux-user/loader.h                     |  21 +
linux-user/loongarch64/target_elf.h     |  13 +
linux-user/loongarch64/target_ptrace.h  |  15 +
linux-user/loongarch64/target_syscall.h |  23 -
linux-user/m68k/target_elf.h            |  27 +
linux-user/m68k/target_syscall.h        |  16 -
linux-user/microblaze/target_elf.h      |  17 +
linux-user/microblaze/target_ptrace.h   |  20 +
linux-user/microblaze/target_syscall.h  |  44 --
linux-user/mips/target_elf.h            |  15 +
linux-user/mips/target_ptrace.h         |  17 +
linux-user/mips/target_syscall.h        |  19 -
linux-user/mips64/target_elf.h          |  21 +
linux-user/mips64/target_ptrace.h       |  16 +
linux-user/mips64/target_syscall.h      |  16 -
linux-user/openrisc/target_elf.h        |  15 +
linux-user/openrisc/target_ptrace.h     |  13 +
linux-user/openrisc/target_syscall.h    |  11 -
linux-user/ppc/target_elf.h             |  56 ++
linux-user/ppc/target_ptrace.h          |  26 +
linux-user/ppc/target_syscall.h         |  28 -
linux-user/riscv/target_elf.h           |  10 +
linux-user/riscv/target_syscall.h       |  35 -
linux-user/s390x/target_elf.h           |  15 +
linux-user/s390x/target_ptrace.h        |  18 +
linux-user/s390x/target_syscall.h       |  22 -
linux-user/sh4/target_elf.h             |  14 +
linux-user/sh4/target_ptrace.h          |  18 +
linux-user/sh4/target_syscall.h         |  11 -
linux-user/sparc/target_elf.h           |  11 +
linux-user/sparc/target_ptrace.h        |  24 +
linux-user/sparc/target_syscall.h       |  19 -
linux-user/x86_64/target_elf.h          |  16 +
linux-user/x86_64/target_ptrace.h       |  40 ++
linux-user/x86_64/target_syscall.h      |  28 -
linux-user/xtensa/target_elf.h          |  15 +
linux-user/xtensa/target_ptrace.h       |  22 +
linux-user/xtensa/target_syscall.h      |  35 -
linux-user/aarch64/elfload.c            |  29 +
linux-user/arm/elfload.c                |  76 ++
linux-user/elfload.c                    | 918 +-----------------------
linux-user/hppa/elfload.c               |  31 +
linux-user/i386/elfload.c               |  22 +
linux-user/loongarch64/elfload.c        |  15 +
linux-user/m68k/elfload.c               |  25 +
linux-user/microblaze/elfload.c         |  13 +
linux-user/microblaze/signal.c          |  71 +-
linux-user/mips/elfload.c               |  18 +
linux-user/openrisc/elfload.c           |  10 +
linux-user/openrisc/signal.c            |   3 +-
linux-user/ppc/elfload.c                |  15 +
linux-user/s390x/elfload.c              |  14 +
linux-user/s390x/signal.c               |   1 +
linux-user/sh4/elfload.c                |  15 +
linux-user/sparc/signal.c               |   2 +
linux-user/x86_64/elfload.c             |  52 ++
linux-user/xtensa/elfload.c             |  20 +
72 files changed, 1043 insertions(+), 1353 deletions(-)
create mode 100644 linux-user/aarch64/target_ptrace.h
create mode 100644 linux-user/arm/target_ptrace.h
create mode 100644 linux-user/i386/target_ptrace.h
create mode 100644 linux-user/loongarch64/target_ptrace.h
create mode 100644 linux-user/microblaze/target_ptrace.h
create mode 100644 linux-user/mips/target_ptrace.h
create mode 100644 linux-user/mips64/target_ptrace.h
create mode 100644 linux-user/openrisc/target_ptrace.h
create mode 100644 linux-user/ppc/target_ptrace.h
create mode 100644 linux-user/s390x/target_ptrace.h
create mode 100644 linux-user/sh4/target_ptrace.h
create mode 100644 linux-user/sparc/target_ptrace.h
create mode 100644 linux-user/x86_64/target_ptrace.h
create mode 100644 linux-user/xtensa/target_ptrace.h
[PATCH v3 00/87] linux-user: Split up elfload.c
Posted by Richard Henderson 1 month ago
The goal is to kill the massive target ifdef ladder in elfload.c.

The functions get moved to linux-user/target/elfload.c.
The macros get moved to linux-user/target/target_elf.h.
These are mostly use to parameterize include/elf.h or elfload.c.

The init_thread functions, storing into target_pt_regs, have been
merged with target_cpu_copy_regs, copying out of target_pt_regs
into CPUArchState.  Merging these found a few bits of silliness
where pt_regs fields were initialized but not used.  To encourage
this never to return, remove most target_pt_regs and hide the rest
within the relevant signal.c.

Changes for v3:
  - 48 patches merged to master.
  - Don't eliminate target_elf_gregset_t; instead:
    - Convert the array to a struct, which can be declared abstract,
    - Move ptrace-y structure to target_ptrace.h, if applicable.
    - Use it to define target_elf_gregset_t.
    This resolves Peter's primary objection to v2, which over-simplified
    the interface to elf_core_copy_regs.  As an added benefit, cleans up
    some other really ugly bits.

r~

Richard Henderson (87):
  linux-user/x86_64: Convert target_elf_gregset_t to a struct
  linux-user/i386: Convert target_elf_gregset_t to a struct
  linux-user/arm: Convert target_elf_gregset_t to a struct
  linux-user/aarch64: Convert target_elf_gregset_t to a struct
  linux-user/ppc: Convert target_elf_gregset_t to a struct
  linux-user/loongarch64: Convert target_elf_gregset_t to a struct
  linux-user/mips: Convert target_elf_gregset_t to a struct
  linux-user/microblaze: Convert target_elf_gregset_t to a struct
  linux-user/openrisc: Convert target_elf_gregset_t to a struct
  linux-user/sh4: Convert target_elf_gregset_t to a struct
  linux-user/m68k: Convert target_elf_gregset_t to a struct
  linux-user/s390x: Convert target_elf_gregset_t to a struct
  linux-user/xtensa: Convert target_elf_gregset_t to a struct
  linux-user: Update comment for target_elf_gregset_t
  linux-user: Declare elf_core_copy_regs in loader.h
  linux-user: Rename USE_ELF_CORE_DUMP to HAVE_ELF_CORE_DUMP
  linux-user: Move elf_core_copy_regs to {i386,x86_64}/elfload.c
  linux-user: Move elf_core_copy_regs to arm/elfload.c
  linux-user: Move elf_core_copy_regs to aarch64/elfload.c
  linux-user: Move elf_core_copy_regs to ppc/elfload.c
  linux-user: Move elf_core_copy_regs to loongarch64/elfload.c
  linux-user: Move elf_core_copy_regs to mips/elfload.c
  linux-user: Move elf_core_copy_regs to microblaze/elfload.c
  linux-user: Move elf_core_copy_regs to openrisc/elfload.c
  linux-user: Move elf_core_copy_regs to sh4/elfload.c
  linux-user: Move elf_core_copy_regs to m68k/elfload.c
  linux-user: Move elf_core_copy_regs to s390x/elfload.c
  linux-user: Move elf_core_copy_regs to xtensa/elfload.c
  linux-user: Remove target_elf_greg_t, tswapreg from elfload.c
  linux-user/i386: Create target_ptrace.h
  linux-user/i386: Expand target_elf_gregset_t
  linux-user/x86_64: Create target_ptrace.h
  linux-user/x86_64: Expand target_elf_gregset_t
  linux-user/x86_64: Fix dump of fs_base, gs_base
  linux-user/aarch64: Create target_ptrace.h
  linux-user/aarch64: Expand target_elf_gregset_t
  linux-user/arm: Create target_ptrace.h
  linux-user/arm: Expand target_elf_gregset_t
  linux-user/loongarch64: Create target_ptrace.h
  linux-user/loongarch64: Expand target_elf_gregset_t
  linux-user/m68k: Expand target_elf_gregset_t
  linux-user/microblaze: Create target_ptrace.h
  linux-user/microblaze: Fold target_pt_regs.r* to an array
  linux-user/microblaze: Expand target_elf_gregset_t
  linux-user/mips: Create target_ptrace.h
  linux-user/mips: Use target_ulong for target_elf_greg_t
  linux-user/openrisc: Create target_ptrace.h
  linux-user/openrisc: Expand target_elf_gregset_t
  linux-user/ppc: Create target_ptrace.h
  linux-user/ppc: Expand target_elf_gregset_t
  linux-user/s390x: Create target_ptrace.h
  linux-user/s390x: Expand target_elf_gregset_t
  linux-user/sh4: Create target_ptrace.h
  linux-user/sh4: Expand target_elf_gregset_t
  linux-user/xtensa: Create target_ptrace.h
  linux-user/xtensa: Expand target_elf_gregset_t
  linux-user: Move init_guest_commpage to x86_64/elfload.c
  linux-user: Move init_guest_commpage to arm/elfload.c
  linux-user: Move init_guest_commpage to hppa/elfload.c
  linux-user: Replace init_guest_commpage macro with function
  linux-user: Move get_vdso_image_info to arm/elfload.c
  linux-user: Remove ELF_EXEC_PAGESIZE
  linux-user: Remove redundant ELF_DATA definitons
  linux-user: Move elf parameters to {i386,x86_64}/target_elf.h
  linux-user: Move elf parameters to {arm,aarch64}/target_elf.h
  linux-user: Move elf parameters to sparc/target_elf.h
  linux-user: Move elf parameters to ppc/target_elf.h
  linux-user: Move elf parameters to loongarch64/target_elf.h
  linux-user: Move elf parameters to {mips,mips64}/target_elf.h
  linux-user: Move elf parameters to microblaze/target_elf.h
  linux-user: Move elf parameters to openrisc/target_elf.h
  linux-user: Move elf parameters to sh4/target_elf.h
  linux-user: Move elf parameters to m68k/target_elf.h
  linux-user: Move elf parameters to alpha/target_elf.h
  linux-user: Move elf parameters to s390x/target_elf.h
  linux-user: Move elf parameters to riscv/target_elf.h
  linux-user: Move elf parameters to hppa/target_elf.h
  linux-user: Move elf parameters to xtensa/target_elf.h
  linux-user: Move elf parameters to hexagon/target_elf.h
  linux-user: Standardize on ELF_MACHINE not ELF_ARCH
  linux-user: Rename elf_check_arch
  linux-user: Remove ELIBBAD from elfload.c
  linux-user: Remove MAP_DENYWRITE from elfload.c
  linux-user: Move arch_parse_elf_property to aarch64/elfload.c
  linux-user: Remove a.out declarations from elfload.c
  linux-user/sparc: Create target_ptrace.h
  linux-user: Remove target_pt_regs from target_syscall.h

 linux-user/aarch64/target_elf.h         |  21 +
 linux-user/aarch64/target_ptrace.h      |  14 +
 linux-user/aarch64/target_syscall.h     |   7 -
 linux-user/alpha/target_elf.h           |   3 +
 linux-user/alpha/target_syscall.h       |  40 --
 linux-user/arm/target_elf.h             |  18 +
 linux-user/arm/target_ptrace.h          |  16 +
 linux-user/arm/target_syscall.h         |   8 -
 linux-user/hexagon/target_elf.h         |   3 +
 linux-user/hexagon/target_syscall.h     |   5 -
 linux-user/hppa/target_elf.h            |   8 +
 linux-user/hppa/target_syscall.h        |  18 -
 linux-user/i386/target_elf.h            |  34 +
 linux-user/i386/target_ptrace.h         |  31 +
 linux-user/i386/target_syscall.h        |  18 -
 linux-user/loader.h                     |  21 +
 linux-user/loongarch64/target_elf.h     |  13 +
 linux-user/loongarch64/target_ptrace.h  |  15 +
 linux-user/loongarch64/target_syscall.h |  23 -
 linux-user/m68k/target_elf.h            |  27 +
 linux-user/m68k/target_syscall.h        |  16 -
 linux-user/microblaze/target_elf.h      |  17 +
 linux-user/microblaze/target_ptrace.h   |  20 +
 linux-user/microblaze/target_syscall.h  |  44 --
 linux-user/mips/target_elf.h            |  15 +
 linux-user/mips/target_ptrace.h         |  17 +
 linux-user/mips/target_syscall.h        |  19 -
 linux-user/mips64/target_elf.h          |  21 +
 linux-user/mips64/target_ptrace.h       |  16 +
 linux-user/mips64/target_syscall.h      |  16 -
 linux-user/openrisc/target_elf.h        |  15 +
 linux-user/openrisc/target_ptrace.h     |  13 +
 linux-user/openrisc/target_syscall.h    |  11 -
 linux-user/ppc/target_elf.h             |  56 ++
 linux-user/ppc/target_ptrace.h          |  26 +
 linux-user/ppc/target_syscall.h         |  28 -
 linux-user/riscv/target_elf.h           |  10 +
 linux-user/riscv/target_syscall.h       |  35 -
 linux-user/s390x/target_elf.h           |  15 +
 linux-user/s390x/target_ptrace.h        |  18 +
 linux-user/s390x/target_syscall.h       |  22 -
 linux-user/sh4/target_elf.h             |  14 +
 linux-user/sh4/target_ptrace.h          |  18 +
 linux-user/sh4/target_syscall.h         |  11 -
 linux-user/sparc/target_elf.h           |  11 +
 linux-user/sparc/target_ptrace.h        |  24 +
 linux-user/sparc/target_syscall.h       |  19 -
 linux-user/x86_64/target_elf.h          |  16 +
 linux-user/x86_64/target_ptrace.h       |  40 ++
 linux-user/x86_64/target_syscall.h      |  28 -
 linux-user/xtensa/target_elf.h          |  15 +
 linux-user/xtensa/target_ptrace.h       |  22 +
 linux-user/xtensa/target_syscall.h      |  35 -
 linux-user/aarch64/elfload.c            |  29 +
 linux-user/arm/elfload.c                |  76 ++
 linux-user/elfload.c                    | 918 +-----------------------
 linux-user/hppa/elfload.c               |  31 +
 linux-user/i386/elfload.c               |  22 +
 linux-user/loongarch64/elfload.c        |  15 +
 linux-user/m68k/elfload.c               |  25 +
 linux-user/microblaze/elfload.c         |  13 +
 linux-user/microblaze/signal.c          |  71 +-
 linux-user/mips/elfload.c               |  18 +
 linux-user/openrisc/elfload.c           |  10 +
 linux-user/openrisc/signal.c            |   3 +-
 linux-user/ppc/elfload.c                |  15 +
 linux-user/s390x/elfload.c              |  14 +
 linux-user/s390x/signal.c               |   1 +
 linux-user/sh4/elfload.c                |  15 +
 linux-user/sparc/signal.c               |   2 +
 linux-user/x86_64/elfload.c             |  52 ++
 linux-user/xtensa/elfload.c             |  20 +
 72 files changed, 1043 insertions(+), 1353 deletions(-)
 create mode 100644 linux-user/aarch64/target_ptrace.h
 create mode 100644 linux-user/arm/target_ptrace.h
 create mode 100644 linux-user/i386/target_ptrace.h
 create mode 100644 linux-user/loongarch64/target_ptrace.h
 create mode 100644 linux-user/microblaze/target_ptrace.h
 create mode 100644 linux-user/mips/target_ptrace.h
 create mode 100644 linux-user/mips64/target_ptrace.h
 create mode 100644 linux-user/openrisc/target_ptrace.h
 create mode 100644 linux-user/ppc/target_ptrace.h
 create mode 100644 linux-user/s390x/target_ptrace.h
 create mode 100644 linux-user/sh4/target_ptrace.h
 create mode 100644 linux-user/sparc/target_ptrace.h
 create mode 100644 linux-user/x86_64/target_ptrace.h
 create mode 100644 linux-user/xtensa/target_ptrace.h

-- 
2.43.0
Re: [PATCH v3 00/87] linux-user: Split up elfload.c
Posted by Peter Maydell 1 month ago
On Thu, 28 Aug 2025 at 13:08, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> The goal is to kill the massive target ifdef ladder in elfload.c.
>
> The functions get moved to linux-user/target/elfload.c.
> The macros get moved to linux-user/target/target_elf.h.
> These are mostly use to parameterize include/elf.h or elfload.c.
>
> The init_thread functions, storing into target_pt_regs, have been
> merged with target_cpu_copy_regs, copying out of target_pt_regs
> into CPUArchState.  Merging these found a few bits of silliness
> where pt_regs fields were initialized but not used.  To encourage
> this never to return, remove most target_pt_regs and hide the rest
> within the relevant signal.c.
>
> Changes for v3:
>   - 48 patches merged to master.
>   - Don't eliminate target_elf_gregset_t; instead:
>     - Convert the array to a struct, which can be declared abstract,
>     - Move ptrace-y structure to target_ptrace.h, if applicable.
>     - Use it to define target_elf_gregset_t.
>     This resolves Peter's primary objection to v2, which over-simplified
>     the interface to elf_core_copy_regs.  As an added benefit, cleans up
>     some other really ugly bits.

I think I've reviewed all of these patches now -- ping me
if I missed one.

thanks
-- PMM