[00/23] nptl: Move almost all remaining functions into libc

Message ID cover.1620838411.git.fweimer@redhat.com
Headers show
Series
  • nptl: Move almost all remaining functions into libc
Related show

Message

Andreas K. Huettel via Libc-alpha May 12, 2021, 4:57 p.m.
I had to fix initialization of the dormant _rtld_global_ro after static
dlopen because I was running into issues because threading
initialization depends on data from _rtld_global_ro, and that
increasingly happens even without libpthread linked in.

Tested on aarch64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
x86_64-linux-gnu.  Built with build-many-glibcs-py.

For pthread_create, I'm running into issues related to libthread_db
integration (the structure definition).  But with the current series,
debugging should still work (as verified by the GDB attach test).

Thanks,
Florian

Florian Weimer (23):
  nptl: Move __nptl_initial_report_events into ld.so/startup code
  nptl: Move __nptl_create_event, __nptl_death_event into libc
  elf: Partially initialize ld.so after static dlopen (bug 20802)
  aarch64: Remove _dl_var_init
  arc: Remove _dl_var_init
  ia64: Remove _dl_var_init
  m68k: Remove _dl_var_init
  mips: Remove _dl_var_init
  powerpc: Remove _dl_var_init
  elf: Remove DL_STATIC_INIT
  elf: Move static TLS size and alignment into _rtld_global_ro
  nptl: Introduce __nptl_deferred_init
  nptl: Eliminate the __static_tls_size, __static_tls_align_m1 variables
  nptl: Move pthread_getattr_default_np into libc
  nptl: Remove unused nptl/pthread_getcpuclockid.c implementation
  Linux: Move implementation of pthread_getcpuclockid to nptl directory
  nptl: Move pthread_getcpuclockid into libc
  nptl: Move pthread_getname_np into libc
  nptl: Move pthread_setaffinity_np into libc
  nptl: Move pthread_setname_np into libc
  nptl: Move pthread_setschedprio into libc
  nptl: Move pthread_sigqueue into libc
  nptl: Move semi-public __pthread_get_minstack symbol into libc

 dlfcn/tststatic5.c                            |  11 +-
 elf/Makefile                                  |  11 +-
 elf/dl-open.c                                 |  21 ++-
 elf/dl-reloc.c                                |   6 +-
 elf/dl-tls.c                                  |  27 ++--
 elf/rtld_static_init.c                        |  62 ++++++++
 elf/static-stubs.c                            |  14 ++
 .../aarch64/ldsodefs.h => elf/tst-auxvalmod.c |  34 ++--
 elf/tst-getauxval-static.c                    |  66 ++++++++
 nptl/Makefile                                 |  16 +-
 nptl/Versions                                 |  47 ++++--
 nptl/allocatestack.c                          |  25 +--
 nptl/events.c                                 |   4 +-
 nptl/libpthread-compat.c                      |  36 +++++
 nptl/nptl-init.c                              | 148 +-----------------
 nptl/nptl-stack.c                             |  17 ++
 nptl/nptl-stack.h                             |  11 +-
 nptl/pthreadP.h                               |  33 ++--
 nptl/pthread_cancel.c                         |  84 ++++++++++
 nptl/pthread_create.c                         |  12 +-
 nptl/pthread_getattr_default_np.c             |  14 +-
 nptl/pthread_getcpuclockid.c                  |  35 ++---
 nptl/pthread_getname.c                        |  14 +-
 nptl/pthread_setaffinity.c                    |  10 +-
 nptl/pthread_setname.c                        |  11 +-
 nptl/pthread_setschedprio.c                   |  13 +-
 nptl/pthread_sigqueue.c                       |  11 +-
 nptl_db/db-symbols.awk                        |   1 +
 nptl_db/db_info.c                             |   3 -
 nptl_db/structs.def                           |  13 +-
 nptl_db/td_thr_get_info.c                     |  11 +-
 sysdeps/generic/ldsodefs.h                    |  23 +--
 .../ldsodefs.h => generic/rtld_static_init.h} |  24 +--
 sysdeps/nptl/dl-tls_init_tp.c                 |   8 +
 sysdeps/nptl/pthread_early_init.h             |  28 ++++
 sysdeps/unix/sysv/linux/aarch64/Makefile      |   7 -
 sysdeps/unix/sysv/linux/aarch64/Versions      |   6 -
 sysdeps/unix/sysv/linux/aarch64/dl-static.c   |  84 ----------
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |  14 ++
 .../sysv/linux/aarch64/libpthread.abilist     |   8 +-
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |  15 ++
 .../unix/sysv/linux/alpha/libpthread.abilist  |  14 +-
 sysdeps/unix/sysv/linux/arc/Makefile          |   7 -
 sysdeps/unix/sysv/linux/arc/Versions          |   6 -
 sysdeps/unix/sysv/linux/arc/dl-static.c       |  84 ----------
 sysdeps/unix/sysv/linux/arc/libc.abilist      |  14 ++
 .../unix/sysv/linux/arc/libpthread.abilist    |   7 -
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  14 ++
 .../unix/sysv/linux/arm/be/libpthread.abilist |  10 +-
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  14 ++
 .../unix/sysv/linux/arm/le/libpthread.abilist |  10 +-
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  14 ++
 .../unix/sysv/linux/csky/libpthread.abilist   |   7 -
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  15 ++
 .../unix/sysv/linux/hppa/libpthread.abilist   |  13 +-
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  15 ++
 .../unix/sysv/linux/i386/libpthread.abilist   |  14 +-
 sysdeps/unix/sysv/linux/ia64/Makefile         |   4 -
 sysdeps/unix/sysv/linux/ia64/Versions         |   5 -
 sysdeps/unix/sysv/linux/ia64/dl-static.c      |  61 --------
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |  15 ++
 .../unix/sysv/linux/ia64/libpthread.abilist   |  13 +-
 .../{arc/ldsodefs.h => ia64/static-stubs.c}   |  24 ++-
 sysdeps/unix/sysv/linux/m68k/Makefile         |   1 -
 sysdeps/unix/sysv/linux/m68k/Versions         |   5 -
 .../sysv/linux/m68k/coldfire/libc.abilist     |  14 ++
 .../linux/m68k/coldfire/libpthread.abilist    |  10 +-
 sysdeps/unix/sysv/linux/m68k/dl-static.c      |  84 ----------
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  15 ++
 .../sysv/linux/m68k/m680x0/libpthread.abilist |  14 +-
 .../sysv/linux/microblaze/be/libc.abilist     |  14 ++
 .../linux/microblaze/be/libpthread.abilist    |   7 -
 .../sysv/linux/microblaze/le/libc.abilist     |  14 ++
 .../linux/microblaze/le/libpthread.abilist    |   7 -
 sysdeps/unix/sysv/linux/mips/Makefile         |   4 -
 sysdeps/unix/sysv/linux/mips/Versions         |   6 -
 sysdeps/unix/sysv/linux/mips/dl-static.c      |  84 ----------
 sysdeps/unix/sysv/linux/mips/ldsodefs.h       |   6 -
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  15 ++
 .../sysv/linux/mips/mips32/libpthread.abilist |  13 +-
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  15 ++
 .../sysv/linux/mips/mips64/libpthread.abilist |  13 +-
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  15 ++
 .../sysv/linux/mips/mips64/n64/libc.abilist   |  15 ++
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  14 ++
 .../unix/sysv/linux/nios2/libpthread.abilist  |   7 -
 sysdeps/unix/sysv/linux/powerpc/Makefile      |   4 -
 sysdeps/unix/sysv/linux/powerpc/Versions      |   6 -
 sysdeps/unix/sysv/linux/powerpc/dl-static.c   |  96 ------------
 sysdeps/unix/sysv/linux/powerpc/ldsodefs.h    |  33 ----
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  15 ++
 .../powerpc/powerpc32/libpthread.abilist      |  14 +-
 .../powerpc/powerpc32/nofpu/libc.abilist      |  15 ++
 .../linux/powerpc/powerpc64/be/libc.abilist   |  15 ++
 .../powerpc/powerpc64/be/libpthread.abilist   |  13 +-
 .../linux/powerpc/powerpc64/le/libc.abilist   |  14 ++
 .../powerpc/powerpc64/le/libpthread.abilist   |   8 +-
 .../ldsodefs.h => powerpc/rtld_static_init.h} |  25 ++-
 .../unix/sysv/linux/pthread_getcpuclockid.c   |  42 -----
 .../unix/sysv/linux/riscv/rv32/libc.abilist   |  14 ++
 .../sysv/linux/riscv/rv32/libpthread.abilist  |   7 -
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |  14 ++
 .../sysv/linux/riscv/rv64/libpthread.abilist  |   7 -
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  15 ++
 .../linux/s390/s390-32/libpthread.abilist     |  14 +-
 .../unix/sysv/linux/s390/s390-64/libc.abilist |  15 ++
 .../linux/s390/s390-64/libpthread.abilist     |  13 +-
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  15 ++
 .../unix/sysv/linux/sh/be/libpthread.abilist  |  13 +-
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  15 ++
 .../unix/sysv/linux/sh/le/libpthread.abilist  |  13 +-
 .../sysv/linux/sparc/sparc32/libc.abilist     |  15 ++
 .../linux/sparc/sparc32/libpthread.abilist    |  14 +-
 .../sysv/linux/sparc/sparc64/libc.abilist     |  15 ++
 .../linux/sparc/sparc64/libpthread.abilist    |  13 +-
 .../unix/sysv/linux/x86_64/64/libc.abilist    |  15 ++
 .../sysv/linux/x86_64/64/libpthread.abilist   |  13 +-
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |  14 ++
 .../sysv/linux/x86_64/x32/libpthread.abilist  |   8 +-
 119 files changed, 1161 insertions(+), 1211 deletions(-)
 create mode 100644 elf/rtld_static_init.c
 rename sysdeps/unix/sysv/linux/aarch64/ldsodefs.h => elf/tst-auxvalmod.c (56%)
 create mode 100644 elf/tst-getauxval-static.c
 rename sysdeps/{unix/sysv/linux/ia64/ldsodefs.h => generic/rtld_static_init.h} (59%)
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/dl-static.c
 delete mode 100644 sysdeps/unix/sysv/linux/arc/dl-static.c
 delete mode 100644 sysdeps/unix/sysv/linux/ia64/dl-static.c
 rename sysdeps/unix/sysv/linux/{arc/ldsodefs.h => ia64/static-stubs.c} (60%)
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/dl-static.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/dl-static.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/dl-static.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/ldsodefs.h
 rename sysdeps/unix/sysv/linux/{m68k/ldsodefs.h => powerpc/rtld_static_init.h} (59%)
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_getcpuclockid.c

-- 
2.31.1

Comments

Andreas K. Huettel via Libc-alpha May 17, 2021, 9:12 a.m. | #1
* Florian Weimer via Libc-alpha:

> I had to fix initialization of the dormant _rtld_global_ro after static

> dlopen because I was running into issues because threading

> initialization depends on data from _rtld_global_ro, and that

> increasingly happens even without libpthread linked in.

>

> Tested on aarch64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,

> x86_64-linux-gnu.  Built with build-many-glibcs-py.

>

> For pthread_create, I'm running into issues related to libthread_db

> integration (the structure definition).  But with the current series,

> debugging should still work (as verified by the GDB attach test).


I've pushed the approved parts of this series.

I'll rework the __nptl_deferred_init patch and resubmit.

Thanks,
Florian