unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132]
@ 2021-08-02  4:29 H.J. Lu via Libc-alpha
  2021-08-02  4:29 ` [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130] H.J. Lu via Libc-alpha
  2022-10-06 16:38 ` [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132] Carlos O'Donell via Libc-alpha
  0 siblings, 2 replies; 10+ messages in thread
From: H.J. Lu via Libc-alpha @ 2021-08-02  4:29 UTC (permalink / raw)
  To: libc-alpha

Since the module name of ld is rtld, map ABI/VERSION of rtld to ABI/VERSION
of ld.  This fixes BZ #28132.
---
 scripts/abi-versions.awk | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/scripts/abi-versions.awk b/scripts/abi-versions.awk
index c369793459..09c9432f5c 100644
--- a/scripts/abi-versions.awk
+++ b/scripts/abi-versions.awk
@@ -27,6 +27,11 @@ $2 == "=" {
 
   printf "#define ABI_%s_%s\tABI_%s_%s\n", libid, oldid, libid, newid;
   printf "#define VERSION_%s_%s\t%s\n", libid, oldid, new;
+  if (libid == "ld") {
+    # The module name of ld is rtld.
+    printf "#define ABI_rtld_%s\tABI_ld_%s\n", oldid, oldid
+    printf "#define VERSION_rtld_%s\tVERSION_ld_%s\n", oldid, oldid
+  }
 
   next;
 }
@@ -38,6 +43,11 @@ $2 == "=" {
 
   printf "#define ABI_%s_%s\t%d\t/* support %s */\n", libid, versid, ++n, vers;
   printf "#define VERSION_%s_%s\t%s\n", libid, versid, vers;
+  if (libid == "ld") {
+    # The module name of ld is rtld.
+    printf "#define ABI_rtld_%s\tABI_ld_%s\n", versid, versid
+    printf "#define VERSION_rtld_%s\tVERSION_ld_%s\n", versid, versid
+  }
   next;
 }
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130]
  2021-08-02  4:29 [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132] H.J. Lu via Libc-alpha
@ 2021-08-02  4:29 ` H.J. Lu via Libc-alpha
  2021-08-02 13:29   ` Andreas Schwab
  2022-10-06 16:38 ` [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132] Carlos O'Donell via Libc-alpha
  1 sibling, 1 reply; 10+ messages in thread
From: H.J. Lu via Libc-alpha @ 2021-08-02  4:29 UTC (permalink / raw)
  To: libc-alpha

<link.h> has

extern struct r_debug _r_debug;

which is exported from ld.so.  rtld.c has

  /* Initialize _r_debug.  */
  struct r_debug *r = _dl_debug_initialize (GL(dl_rtld_map).l_addr,
                                            LM_ID_BASE);
...
  if (main_map->l_info[DT_DEBUG] != NULL)
    /* There is a DT_DEBUG entry in the dynamic section.  Fill it in
       with the run-time address of the r_debug structure  */
    main_map->l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r;

With COPY relocation, the address of _r_debug at run-time may be in the
executable if it references _r_debug.  Since debugger uses DT_DEBUG, it
will reference the staled original definition of _r_debug in ld.so.

1. Add a function, __r_debug_location, which returns the address of
_r_debug:

/* Return the address of that structure used by the dynamic linker.  */
extern struct r_debug * __r_debug_location (void) __attribute_const__;

It has a special glibc version, GLIBC_DEBUG.

2. Hide _r_debug in ld.so by defining _r_debug with __r_debug_location:

 #define _r_debug (*__r_debug_location ())

The existing dynamic executables with _r_debug reference will get a copy
of _r_debug which won't be updated by ld.so.  But DT_DEBUG will work with
debuggers.
3. The static executables linked against glibc 2.35 will get the _r_debug
symbol from __r_debug_location definition in libc.a.

This fixes BZ #28130.
---
 elf/Makefile                                  | 14 +++-
 elf/Versions                                  |  4 ++
 elf/dl-debug.c                                | 23 ++++--
 elf/link.h                                    |  5 +-
 elf/tst-dlopen-static.c                       | 71 +++++++++++++++++++
 sysdeps/mach/hurd/i386/ld.abilist             |  1 +
 sysdeps/unix/sysv/linux/aarch64/ld.abilist    |  1 +
 sysdeps/unix/sysv/linux/alpha/ld.abilist      |  1 +
 sysdeps/unix/sysv/linux/arc/ld.abilist        |  1 +
 sysdeps/unix/sysv/linux/arm/be/ld.abilist     |  1 +
 sysdeps/unix/sysv/linux/arm/le/ld.abilist     |  1 +
 sysdeps/unix/sysv/linux/csky/ld.abilist       |  1 +
 sysdeps/unix/sysv/linux/hppa/ld.abilist       |  1 +
 sysdeps/unix/sysv/linux/i386/ld.abilist       |  1 +
 sysdeps/unix/sysv/linux/ia64/ld.abilist       |  1 +
 .../unix/sysv/linux/m68k/coldfire/ld.abilist  |  1 +
 .../unix/sysv/linux/m68k/m680x0/ld.abilist    |  1 +
 sysdeps/unix/sysv/linux/microblaze/ld.abilist |  1 +
 .../unix/sysv/linux/mips/mips32/ld.abilist    |  1 +
 .../sysv/linux/mips/mips64/n32/ld.abilist     |  1 +
 .../sysv/linux/mips/mips64/n64/ld.abilist     |  1 +
 sysdeps/unix/sysv/linux/nios2/ld.abilist      |  1 +
 .../sysv/linux/powerpc/powerpc32/ld.abilist   |  1 +
 .../linux/powerpc/powerpc64/be/ld.abilist     |  1 +
 .../linux/powerpc/powerpc64/le/ld.abilist     |  1 +
 sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist |  1 +
 sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist |  1 +
 .../unix/sysv/linux/s390/s390-32/ld.abilist   |  1 +
 .../unix/sysv/linux/s390/s390-64/ld.abilist   |  1 +
 sysdeps/unix/sysv/linux/sh/be/ld.abilist      |  1 +
 sysdeps/unix/sysv/linux/sh/le/ld.abilist      |  1 +
 .../unix/sysv/linux/sparc/sparc32/ld.abilist  |  1 +
 .../unix/sysv/linux/sparc/sparc64/ld.abilist  |  1 +
 sysdeps/unix/sysv/linux/x86_64/64/ld.abilist  |  1 +
 sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist |  1 +
 35 files changed, 139 insertions(+), 8 deletions(-)
 create mode 100644 elf/tst-dlopen-static.c

diff --git a/elf/Makefile b/elf/Makefile
index d05f410592..8fad633d2c 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -187,11 +187,14 @@ tests-internal := tst-tls1 tst-tls2 $(tests-static-internal)
 tests-static := $(tests-static-normal) $(tests-static-internal)
 
 ifeq (yes,$(build-shared))
-tests-static += tst-tls9-static tst-single_threaded-static-dlopen
+tests-static += tst-tls9-static tst-single_threaded-static-dlopen \
+	tst-dlopen-static
+tests-special += $(objpfx)tst-dlopen-static-_r_debug.out
 static-dlopen-environment = \
   LD_LIBRARY_PATH=$(ld-library-path):$(common-objpfx)dlfcn
 tst-tls9-static-ENV = $(static-dlopen-environment)
 tst-single_threaded-static-dlopen-ENV = $(static-dlopen-environment)
+tst-dlopen-static-ENV = $(static-dlopen-environment)
 
 tests += restest1 preloadtest loadfail multiload origtest resolvfail \
 	 constload1 order noload filter \
@@ -609,6 +612,8 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
 	$(call after-link,$@.new)
 	$(READELF) -s $@.new \
 	  | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
+	$(READELF) -rW $@.new \
+	  | $(AWK) '($$5 ~/_r_debug/) { print; p=1 } END { exit p != 0 }'
 	mv -f $@.new $@
 
 ifeq (yes,$(build-shared))
@@ -1710,6 +1715,13 @@ $(objpfx)tst-single_threaded-pthread.out: \
   $(objpfx)tst-single_threaded-mod4.so
 $(objpfx)tst-single_threaded-pthread-static: $(static-thread-library)
 
+$(objpfx)tst-dlopen-static: $(objpfx)tst-single_threaded-mod1.o
+$(objpfx)tst-dlopen-static.out: $(objpfx)tst-single_threaded-mod2.so
+$(objpfx)tst-dlopen-static-_r_debug.out: $(objpfx)tst-dlopen-static
+	$(READELF) -sW $< \
+	  | $(AWK) '($$8 ~ /_r_debug$$/) { print; p=1 } END { exit p == 0 }' > $@
+	$(evaluate-test)
+
 $(objpfx)tst-tls-ie: $(shared-thread-library)
 $(objpfx)tst-tls-ie.out: \
   $(objpfx)tst-tls-ie-mod0.so \
diff --git a/elf/Versions b/elf/Versions
index 775aab62af..75170f2ebc 100644
--- a/elf/Versions
+++ b/elf/Versions
@@ -48,6 +48,10 @@ ld {
     # stack canary
     __stack_chk_guard;
   }
+  GLIBC_DEBUG {
+    # Adddess of _r_debug
+    __r_debug_location;
+  }
   GLIBC_PRIVATE {
     # Those are in the dynamic linker, but used by libc.so.
     __libc_enable_secure;
diff --git a/elf/dl-debug.c b/elf/dl-debug.c
index 2cd5f09753..6ae9d7839f 100644
--- a/elf/dl-debug.c
+++ b/elf/dl-debug.c
@@ -17,7 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <ldsodefs.h>
-
+#include <shlib-compat.h>
 
 /* These are the members in the public `struct link_map' type.
    Sanity check that the internal type and the public type match.  */
@@ -34,11 +34,19 @@ extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr)
    normally finds it via the DT_DEBUG entry in the dynamic section, but in
    a statically-linked program there is no dynamic section for the debugger
    to examine and it looks for this particular symbol name.  */
+#undef _r_debug
 struct r_debug _r_debug;
 
+extern struct r_debug _r_debug_internal attribute_hidden;
+strong_alias (_r_debug, _r_debug_internal)
+
+#if SHLIB_COMPAT (rtld, GLIBC_2_0, GLIBC_2_34)
+strong_alias (_r_debug, _r_debug_compat)
+compat_symbol (rtld, _r_debug_compat, _r_debug, GLIBC_2_0);
+#endif
 
-/* Initialize _r_debug if it has not already been done.  The argument is
-   the run-time load address of the dynamic linker, to be put in
+/* Initialize _r_debug if it has not already been done.  The argument
+   is the run-time load address of the dynamic linker, to be put in
    _r_debug.r_ldbase.  Returns the address of _r_debug.  */
 
 struct r_debug *
@@ -47,7 +55,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
   struct r_debug *r;
 
   if (ns == LM_ID_BASE)
-    r = &_r_debug;
+    r = &_r_debug_internal;
   else
     r = &GL(dl_ns)[ns]._ns_debug;
 
@@ -55,7 +63,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
     {
       /* Tell the debugger where to find the map of loaded objects.  */
       r->r_version = 1	/* R_DEBUG_VERSION XXX */;
-      r->r_ldbase = ldbase ?: _r_debug.r_ldbase;
+      r->r_ldbase = ldbase ?: _r_debug_internal.r_ldbase;
       r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded;
       r->r_brk = (ElfW(Addr)) &_dl_debug_state;
     }
@@ -63,6 +71,11 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns)
   return r;
 }
 
+struct r_debug *
+__r_debug_location (void)
+{
+  return &_r_debug_internal;
+}
 
 /* This function exists solely to have a breakpoint set on it by the
    debugger.  The debugger is supposed to find this function's address by
diff --git a/elf/link.h b/elf/link.h
index ff3a85c847..17477a2409 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -63,8 +63,9 @@ struct r_debug
     ElfW(Addr) r_ldbase;	/* Base address the linker is loaded at.  */
   };
 
-/* This is the instance of that structure used by the dynamic linker.  */
-extern struct r_debug _r_debug;
+/* Return the address of that structure used by the dynamic linker.  */
+extern struct r_debug * __r_debug_location (void) __attribute_const__;
+#define _r_debug (*__r_debug_location ())
 
 /* This symbol refers to the "dynamic structure" in the `.dynamic' section
    of whatever module refers to `_DYNAMIC'.  So, to find its own
diff --git a/elf/tst-dlopen-static.c b/elf/tst-dlopen-static.c
new file mode 100644
index 0000000000..e9e06c0873
--- /dev/null
+++ b/elf/tst-dlopen-static.c
@@ -0,0 +1,71 @@
+/* Test static dlopen with _r_debug.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+#include <link.h>
+#include <support/check.h>
+#include <support/xdlfcn.h>
+#include <sys/single_threaded.h>
+
+static int
+do_test (void)
+{
+  TEST_VERIFY (__libc_single_threaded);
+
+  /* Defined in tst-single-threaded-mod1.o.  */
+  extern _Bool single_threaded_1 (void);
+  TEST_VERIFY (single_threaded_1 ());
+
+  /* A failed dlopen does not change the multi-threaded status.  */
+  TEST_VERIFY (dlopen ("tst-single_threaded-does-not-exist.so", RTLD_LAZY)
+               == NULL);
+  TEST_VERIFY (__libc_single_threaded);
+  TEST_VERIFY (single_threaded_1 ());
+
+  /* And neither does a successful dlopen for outer (static) libc.  */
+  const char *mod2 = "tst-single_threaded-mod2.so";
+  void *handle_mod2 = xdlopen (mod2, RTLD_LAZY);
+  _Bool (*single_threaded_2) (void)
+    = xdlsym (handle_mod2, "single_threaded_2");
+  TEST_VERIFY (__libc_single_threaded);
+  TEST_VERIFY (single_threaded_1 ());
+  /* The inner libc always assumes multi-threaded use.  */
+  TEST_VERIFY (!single_threaded_2 ());
+
+  /* Check the working _r_debug.  */
+  struct link_map *map;
+  int missing_mod2 = 1;
+  for (map = _r_debug.r_map; map != NULL; map = map->l_next)
+    {
+      const char *name = basename (map->l_name);
+      printf ("module name = '%s'\n", name);
+      if (strcmp (mod2, name) == 0)
+	missing_mod2 = 0;
+    }
+
+  if (missing_mod2)
+    FAIL_EXIT1 ("'%s' is missing in _r_debug\n", mod2);
+
+  xdlclose (handle_mod2);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/mach/hurd/i386/ld.abilist b/sysdeps/mach/hurd/i386/ld.abilist
index 7e20c5e7ce..787f3823d2 100644
--- a/sysdeps/mach/hurd/i386/ld.abilist
+++ b/sysdeps/mach/hurd/i386/ld.abilist
@@ -16,3 +16,4 @@ GLIBC_2.2.6 _r_debug D 0x14
 GLIBC_2.2.6 abort F
 GLIBC_2.3 ___tls_get_addr F
 GLIBC_2.3 __tls_get_addr F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/aarch64/ld.abilist b/sysdeps/unix/sysv/linux/aarch64/ld.abilist
index 80b2fe6725..7f9f98d82b 100644
--- a/sysdeps/unix/sysv/linux/aarch64/ld.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.17 __stack_chk_guard D 0x8
 GLIBC_2.17 __tls_get_addr F
 GLIBC_2.17 _dl_mcount F
 GLIBC_2.17 _r_debug D 0x28
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/alpha/ld.abilist b/sysdeps/unix/sysv/linux/alpha/ld.abilist
index 98a03f611f..df2c12874b 100644
--- a/sysdeps/unix/sysv/linux/alpha/ld.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.1 __libc_stack_end D 0x8
 GLIBC_2.1 _dl_mcount F
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.4 __stack_chk_guard D 0x8
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/arc/ld.abilist b/sysdeps/unix/sysv/linux/arc/ld.abilist
index 048f17c848..2ef94c4b0c 100644
--- a/sysdeps/unix/sysv/linux/arc/ld.abilist
+++ b/sysdeps/unix/sysv/linux/arc/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.32 __stack_chk_guard D 0x4
 GLIBC_2.32 __tls_get_addr F
 GLIBC_2.32 _dl_mcount F
 GLIBC_2.32 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/arm/be/ld.abilist b/sysdeps/unix/sysv/linux/arm/be/ld.abilist
index cc8825c3bc..20fe887a08 100644
--- a/sysdeps/unix/sysv/linux/arm/be/ld.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.4 __stack_chk_guard D 0x4
 GLIBC_2.4 __tls_get_addr F
 GLIBC_2.4 _dl_mcount F
 GLIBC_2.4 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/arm/le/ld.abilist b/sysdeps/unix/sysv/linux/arm/le/ld.abilist
index cc8825c3bc..20fe887a08 100644
--- a/sysdeps/unix/sysv/linux/arm/le/ld.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.4 __stack_chk_guard D 0x4
 GLIBC_2.4 __tls_get_addr F
 GLIBC_2.4 _dl_mcount F
 GLIBC_2.4 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/csky/ld.abilist b/sysdeps/unix/sysv/linux/csky/ld.abilist
index 564ac09737..f81f677ac2 100644
--- a/sysdeps/unix/sysv/linux/csky/ld.abilist
+++ b/sysdeps/unix/sysv/linux/csky/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.29 __stack_chk_guard D 0x4
 GLIBC_2.29 __tls_get_addr F
 GLIBC_2.29 _dl_mcount F
 GLIBC_2.29 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/hppa/ld.abilist b/sysdeps/unix/sysv/linux/hppa/ld.abilist
index d155a59843..04eddb99b4 100644
--- a/sysdeps/unix/sysv/linux/hppa/ld.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.2 _dl_mcount F
 GLIBC_2.2 _r_debug D 0x14
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.4 __stack_chk_guard D 0x4
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/i386/ld.abilist b/sysdeps/unix/sysv/linux/i386/ld.abilist
index 0478e22071..7e5e14aaa9 100644
--- a/sysdeps/unix/sysv/linux/i386/ld.abilist
+++ b/sysdeps/unix/sysv/linux/i386/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.1 __libc_stack_end D 0x4
 GLIBC_2.1 _dl_mcount F
 GLIBC_2.3 ___tls_get_addr F
 GLIBC_2.3 __tls_get_addr F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/ia64/ld.abilist b/sysdeps/unix/sysv/linux/ia64/ld.abilist
index 33f91199bf..60753bba7b 100644
--- a/sysdeps/unix/sysv/linux/ia64/ld.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/ld.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8
 GLIBC_2.2 _dl_mcount F
 GLIBC_2.2 _r_debug D 0x28
 GLIBC_2.3 __tls_get_addr F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist
index cc8825c3bc..20fe887a08 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.4 __stack_chk_guard D 0x4
 GLIBC_2.4 __tls_get_addr F
 GLIBC_2.4 _dl_mcount F
 GLIBC_2.4 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist
index 3ba474c27f..0120721413 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.1 __libc_stack_end D 0x4
 GLIBC_2.1 _dl_mcount F
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.4 __stack_chk_guard D 0x4
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/microblaze/ld.abilist b/sysdeps/unix/sysv/linux/microblaze/ld.abilist
index a4933c3541..7ca079e207 100644
--- a/sysdeps/unix/sysv/linux/microblaze/ld.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.18 __stack_chk_guard D 0x4
 GLIBC_2.18 __tls_get_addr F
 GLIBC_2.18 _dl_mcount F
 GLIBC_2.18 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist
index be09641a48..a25c73d95d 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.2 __libc_stack_end D 0x4
 GLIBC_2.2 _dl_mcount F
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.4 __stack_chk_guard D 0x4
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist
index be09641a48..a25c73d95d 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.2 __libc_stack_end D 0x4
 GLIBC_2.2 _dl_mcount F
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.4 __stack_chk_guard D 0x4
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
index 1ea36e13f2..0c93ebf0ca 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.2 __libc_stack_end D 0x8
 GLIBC_2.2 _dl_mcount F
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.4 __stack_chk_guard D 0x8
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/nios2/ld.abilist b/sysdeps/unix/sysv/linux/nios2/ld.abilist
index 52178802dd..63bef92e76 100644
--- a/sysdeps/unix/sysv/linux/nios2/ld.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.21 __stack_chk_guard D 0x4
 GLIBC_2.21 __tls_get_addr F
 GLIBC_2.21 _dl_mcount F
 GLIBC_2.21 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist
index 4bbfba7a61..9ddccbe46e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist
@@ -4,3 +4,4 @@ GLIBC_2.1 _dl_mcount F
 GLIBC_2.22 __tls_get_addr_opt F
 GLIBC_2.23 __parse_hwcap_and_convert_at_platform F
 GLIBC_2.3 __tls_get_addr F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
index 283fb4510b..cf503ddbbf 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/ld.abilist
@@ -4,3 +4,4 @@ GLIBC_2.3 __libc_stack_end D 0x8
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.3 _dl_mcount F
 GLIBC_2.3 _r_debug D 0x28
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
index b1f313c7cd..80c12fbf9d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ld.abilist
@@ -4,3 +4,4 @@ GLIBC_2.17 _dl_mcount F
 GLIBC_2.17 _r_debug D 0x28
 GLIBC_2.22 __tls_get_addr_opt F
 GLIBC_2.23 __parse_hwcap_and_convert_at_platform F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist
index 94ca64c43d..8758f252b1 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.33 __stack_chk_guard D 0x4
 GLIBC_2.33 __tls_get_addr F
 GLIBC_2.33 _dl_mcount F
 GLIBC_2.33 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
index 845f356c3c..57c5fab0e1 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.27 __stack_chk_guard D 0x8
 GLIBC_2.27 __tls_get_addr F
 GLIBC_2.27 _dl_mcount F
 GLIBC_2.27 _r_debug D 0x28
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist
index b56f005beb..71f9172261 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/ld.abilist
@@ -2,3 +2,4 @@ GLIBC_2.0 _r_debug D 0x14
 GLIBC_2.1 __libc_stack_end D 0x4
 GLIBC_2.1 _dl_mcount F
 GLIBC_2.3 __tls_get_offset F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
index 6f788a086d..cc7fd7acf7 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/ld.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8
 GLIBC_2.2 _dl_mcount F
 GLIBC_2.2 _r_debug D 0x28
 GLIBC_2.3 __tls_get_offset F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/sh/be/ld.abilist b/sysdeps/unix/sysv/linux/sh/be/ld.abilist
index d155a59843..04eddb99b4 100644
--- a/sysdeps/unix/sysv/linux/sh/be/ld.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.2 _dl_mcount F
 GLIBC_2.2 _r_debug D 0x14
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.4 __stack_chk_guard D 0x4
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/sh/le/ld.abilist b/sysdeps/unix/sysv/linux/sh/le/ld.abilist
index d155a59843..04eddb99b4 100644
--- a/sysdeps/unix/sysv/linux/sh/le/ld.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/ld.abilist
@@ -3,3 +3,4 @@ GLIBC_2.2 _dl_mcount F
 GLIBC_2.2 _r_debug D 0x14
 GLIBC_2.3 __tls_get_addr F
 GLIBC_2.4 __stack_chk_guard D 0x4
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist
index 0c6610e3c2..7e4b112260 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/ld.abilist
@@ -2,3 +2,4 @@ GLIBC_2.0 _r_debug D 0x14
 GLIBC_2.1 __libc_stack_end D 0x4
 GLIBC_2.1 _dl_mcount F
 GLIBC_2.3 __tls_get_addr F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
index 33f91199bf..60753bba7b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/ld.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2 __libc_stack_end D 0x8
 GLIBC_2.2 _dl_mcount F
 GLIBC_2.2 _r_debug D 0x28
 GLIBC_2.3 __tls_get_addr F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
index d3cdf7611e..dd92378ae1 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/ld.abilist
@@ -2,3 +2,4 @@ GLIBC_2.2.5 __libc_stack_end D 0x8
 GLIBC_2.2.5 _dl_mcount F
 GLIBC_2.2.5 _r_debug D 0x28
 GLIBC_2.3 __tls_get_addr F
+GLIBC_DEBUG __r_debug_location F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist
index c70bccf782..14d41ebcd9 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/ld.abilist
@@ -2,3 +2,4 @@ GLIBC_2.16 __libc_stack_end D 0x4
 GLIBC_2.16 __tls_get_addr F
 GLIBC_2.16 _dl_mcount F
 GLIBC_2.16 _r_debug D 0x14
+GLIBC_DEBUG __r_debug_location F
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130]
  2021-08-02  4:29 ` [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130] H.J. Lu via Libc-alpha
@ 2021-08-02 13:29   ` Andreas Schwab
  2021-08-02 20:43     ` H.J. Lu via Libc-alpha
  2021-08-02 21:19     ` Florian Weimer via Libc-alpha
  0 siblings, 2 replies; 10+ messages in thread
From: Andreas Schwab @ 2021-08-02 13:29 UTC (permalink / raw)
  To: H.J. Lu via Libc-alpha

On Aug 01 2021, H.J. Lu via Libc-alpha wrote:

> 1. Add a function, __r_debug_location, which returns the address of
> _r_debug:
>
> /* Return the address of that structure used by the dynamic linker.  */
> extern struct r_debug * __r_debug_location (void) __attribute_const__;
>
> It has a special glibc version, GLIBC_DEBUG.
>
> 2. Hide _r_debug in ld.so by defining _r_debug with __r_debug_location:
>
>  #define _r_debug (*__r_debug_location ())

There is no need for that.  Nobody should be using _r_debug.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130]
  2021-08-02 13:29   ` Andreas Schwab
@ 2021-08-02 20:43     ` H.J. Lu via Libc-alpha
  2021-08-02 21:19     ` Florian Weimer via Libc-alpha
  1 sibling, 0 replies; 10+ messages in thread
From: H.J. Lu via Libc-alpha @ 2021-08-02 20:43 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: H.J. Lu via Libc-alpha

On Mon, Aug 2, 2021 at 6:29 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Aug 01 2021, H.J. Lu via Libc-alpha wrote:
>
> > 1. Add a function, __r_debug_location, which returns the address of
> > _r_debug:
> >
> > /* Return the address of that structure used by the dynamic linker.  */
> > extern struct r_debug * __r_debug_location (void) __attribute_const__;
> >
> > It has a special glibc version, GLIBC_DEBUG.
> >
> > 2. Hide _r_debug in ld.so by defining _r_debug with __r_debug_location:
> >
> >  #define _r_debug (*__r_debug_location ())
>
> There is no need for that.  Nobody should be using _r_debug.
>

Removed from the v2 patch.

-- 
H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130]
  2021-08-02 13:29   ` Andreas Schwab
  2021-08-02 20:43     ` H.J. Lu via Libc-alpha
@ 2021-08-02 21:19     ` Florian Weimer via Libc-alpha
  2021-08-02 21:46       ` H.J. Lu via Libc-alpha
  1 sibling, 1 reply; 10+ messages in thread
From: Florian Weimer via Libc-alpha @ 2021-08-02 21:19 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: H.J. Lu via Libc-alpha

* Andreas Schwab:

> On Aug 01 2021, H.J. Lu via Libc-alpha wrote:
>
>> 1. Add a function, __r_debug_location, which returns the address of
>> _r_debug:
>>
>> /* Return the address of that structure used by the dynamic linker.  */
>> extern struct r_debug * __r_debug_location (void) __attribute_const__;
>>
>> It has a special glibc version, GLIBC_DEBUG.
>>
>> 2. Hide _r_debug in ld.so by defining _r_debug with __r_debug_location:
>>
>>  #define _r_debug (*__r_debug_location ())
>
> There is no need for that.  Nobody should be using _r_debug.

It's declared in a public header.  GNAT and Spindle use it.  Maybe this
needs to be deprecated first before it can be removed.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130]
  2021-08-02 21:19     ` Florian Weimer via Libc-alpha
@ 2021-08-02 21:46       ` H.J. Lu via Libc-alpha
  2021-08-02 23:06         ` H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu via Libc-alpha @ 2021-08-02 21:46 UTC (permalink / raw)
  To: Florian Weimer; +Cc: H.J. Lu via Libc-alpha, Andreas Schwab

On Mon, Aug 2, 2021 at 2:20 PM Florian Weimer via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> * Andreas Schwab:
>
> > On Aug 01 2021, H.J. Lu via Libc-alpha wrote:
> >
> >> 1. Add a function, __r_debug_location, which returns the address of
> >> _r_debug:
> >>
> >> /* Return the address of that structure used by the dynamic linker.  */
> >> extern struct r_debug * __r_debug_location (void) __attribute_const__;
> >>
> >> It has a special glibc version, GLIBC_DEBUG.
> >>
> >> 2. Hide _r_debug in ld.so by defining _r_debug with __r_debug_location:
> >>
> >>  #define _r_debug (*__r_debug_location ())
> >
> > There is no need for that.  Nobody should be using _r_debug.
>
> It's declared in a public header.  GNAT and Spindle use it.  Maybe this

It is wrong to use it to begin with.

> needs to be deprecated first before it can be removed.

My v2 patch includes an alternative in libsupport.

-- 
H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130]
  2021-08-02 21:46       ` H.J. Lu via Libc-alpha
@ 2021-08-02 23:06         ` H.J. Lu via Libc-alpha
  0 siblings, 0 replies; 10+ messages in thread
From: H.J. Lu via Libc-alpha @ 2021-08-02 23:06 UTC (permalink / raw)
  To: Florian Weimer; +Cc: H.J. Lu via Libc-alpha, Andreas Schwab

On Mon, Aug 2, 2021 at 2:46 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Aug 2, 2021 at 2:20 PM Florian Weimer via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
> >
> > * Andreas Schwab:
> >
> > > On Aug 01 2021, H.J. Lu via Libc-alpha wrote:
> > >
> > >> 1. Add a function, __r_debug_location, which returns the address of
> > >> _r_debug:
> > >>
> > >> /* Return the address of that structure used by the dynamic linker.  */
> > >> extern struct r_debug * __r_debug_location (void) __attribute_const__;
> > >>
> > >> It has a special glibc version, GLIBC_DEBUG.
> > >>
> > >> 2. Hide _r_debug in ld.so by defining _r_debug with __r_debug_location:
> > >>
> > >>  #define _r_debug (*__r_debug_location ())
> > >
> > > There is no need for that.  Nobody should be using _r_debug.
> >
> > It's declared in a public header.  GNAT and Spindle use it.  Maybe this
>
> It is wrong to use it to begin with.

We need to support usages of _r_debug for some applications.

extern struct r_debug * __r_debug_location (void) __attribute_const__;
#define _r_debug (*__r_debug_location ())

works here.

> > needs to be deprecated first before it can be removed.
>
> My v2 patch includes an alternative in libsupport.
>
> --
> H.J.



-- 
H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132]
  2021-08-02  4:29 [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132] H.J. Lu via Libc-alpha
  2021-08-02  4:29 ` [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130] H.J. Lu via Libc-alpha
@ 2022-10-06 16:38 ` Carlos O'Donell via Libc-alpha
  2022-10-06 18:46   ` H.J. Lu via Libc-alpha
  1 sibling, 1 reply; 10+ messages in thread
From: Carlos O'Donell via Libc-alpha @ 2022-10-06 16:38 UTC (permalink / raw)
  To: H.J. Lu; +Cc: libc-alpha

On Sun, Aug 01, 2021 at 09:29:39PM -0700, H.J. Lu via Libc-alpha wrote:
> Since the module name of ld is rtld, map ABI/VERSION of rtld to ABI/VERSION
> of ld.  This fixes BZ #28132.

Reviewing old patches that are still outstanding as part of the queue
review in patchwork. Hopefully we catch up to the point where I'm not
reviewing year old patches in the queue. However, some of these patches
are interesting and valuable so I'm reviving them to review potential
solutions.

In scripts/gen-libc-modules.awk we have this code:
 21   if (name == "ld")
 22     name = "rtld"

This means we are already handling this processing in other places. A
clean solution needs to consider:

scripts/abi-version.awk (no changes, should just use rtld)
scripts/gen-libc-modules.awk (ld vs rtld)
shlib-versions (ld=...)

It feels like we need to refactor from the top just use rtld everywhere
we accidentally used ld as our identifier.

> ---
>  scripts/abi-versions.awk | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/scripts/abi-versions.awk b/scripts/abi-versions.awk
> index c369793459..09c9432f5c 100644
> --- a/scripts/abi-versions.awk
> +++ b/scripts/abi-versions.awk
> @@ -27,6 +27,11 @@ $2 == "=" {
>  
>    printf "#define ABI_%s_%s\tABI_%s_%s\n", libid, oldid, libid, newid;
>    printf "#define VERSION_%s_%s\t%s\n", libid, oldid, new;
> +  if (libid == "ld") {
> +    # The module name of ld is rtld.
> +    printf "#define ABI_rtld_%s\tABI_ld_%s\n", oldid, oldid
> +    printf "#define VERSION_rtld_%s\tVERSION_ld_%s\n", oldid, oldid
> +  }
>  
>    next;
>  }
> @@ -38,6 +43,11 @@ $2 == "=" {
>  
>    printf "#define ABI_%s_%s\t%d\t/* support %s */\n", libid, versid, ++n, vers;
>    printf "#define VERSION_%s_%s\t%s\n", libid, versid, vers;
> +  if (libid == "ld") {
> +    # The module name of ld is rtld.
> +    printf "#define ABI_rtld_%s\tABI_ld_%s\n", versid, versid
> +    printf "#define VERSION_rtld_%s\tVERSION_ld_%s\n", versid, versid
> +  }
>    next;
>  }
>  
> -- 
> 2.31.1
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132]
  2022-10-06 16:38 ` [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132] Carlos O'Donell via Libc-alpha
@ 2022-10-06 18:46   ` H.J. Lu via Libc-alpha
  2022-10-06 19:52     ` H.J. Lu via Libc-alpha
  0 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu via Libc-alpha @ 2022-10-06 18:46 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: libc-alpha

On Thu, Oct 6, 2022 at 9:39 AM Carlos O'Donell <carlos@redhat.com> wrote:
>
> On Sun, Aug 01, 2021 at 09:29:39PM -0700, H.J. Lu via Libc-alpha wrote:
> > Since the module name of ld is rtld, map ABI/VERSION of rtld to ABI/VERSION
> > of ld.  This fixes BZ #28132.
>
> Reviewing old patches that are still outstanding as part of the queue
> review in patchwork. Hopefully we catch up to the point where I'm not
> reviewing year old patches in the queue. However, some of these patches
> are interesting and valuable so I'm reviving them to review potential
> solutions.
>
> In scripts/gen-libc-modules.awk we have this code:
>  21   if (name == "ld")
>  22     name = "rtld"
>
> This means we are already handling this processing in other places. A
> clean solution needs to consider:
>
> scripts/abi-version.awk (no changes, should just use rtld)
> scripts/gen-libc-modules.awk (ld vs rtld)
> shlib-versions (ld=...)
>
> It feels like we need to refactor from the top just use rtld everywhere
> we accidentally used ld as our identifier.

Since LD_SO is defined in lib-names.h, change ld.so to rtld.so requires
scripts/lib-names.awk change.   It is a much bigger and messy change.

> > ---
> >  scripts/abi-versions.awk | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/scripts/abi-versions.awk b/scripts/abi-versions.awk
> > index c369793459..09c9432f5c 100644
> > --- a/scripts/abi-versions.awk
> > +++ b/scripts/abi-versions.awk
> > @@ -27,6 +27,11 @@ $2 == "=" {
> >
> >    printf "#define ABI_%s_%s\tABI_%s_%s\n", libid, oldid, libid, newid;
> >    printf "#define VERSION_%s_%s\t%s\n", libid, oldid, new;
> > +  if (libid == "ld") {
> > +    # The module name of ld is rtld.
> > +    printf "#define ABI_rtld_%s\tABI_ld_%s\n", oldid, oldid
> > +    printf "#define VERSION_rtld_%s\tVERSION_ld_%s\n", oldid, oldid
> > +  }
> >
> >    next;
> >  }
> > @@ -38,6 +43,11 @@ $2 == "=" {
> >
> >    printf "#define ABI_%s_%s\t%d\t/* support %s */\n", libid, versid, ++n, vers;
> >    printf "#define VERSION_%s_%s\t%s\n", libid, versid, vers;
> > +  if (libid == "ld") {
> > +    # The module name of ld is rtld.
> > +    printf "#define ABI_rtld_%s\tABI_ld_%s\n", versid, versid
> > +    printf "#define VERSION_rtld_%s\tVERSION_ld_%s\n", versid, versid
> > +  }
> >    next;
> >  }
> >
> > --
> > 2.31.1
> >
>


--
H.J.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132]
  2022-10-06 18:46   ` H.J. Lu via Libc-alpha
@ 2022-10-06 19:52     ` H.J. Lu via Libc-alpha
  0 siblings, 0 replies; 10+ messages in thread
From: H.J. Lu via Libc-alpha @ 2022-10-06 19:52 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: libc-alpha

On Thu, Oct 6, 2022 at 11:46 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Thu, Oct 6, 2022 at 9:39 AM Carlos O'Donell <carlos@redhat.com> wrote:
> >
> > On Sun, Aug 01, 2021 at 09:29:39PM -0700, H.J. Lu via Libc-alpha wrote:
> > > Since the module name of ld is rtld, map ABI/VERSION of rtld to ABI/VERSION
> > > of ld.  This fixes BZ #28132.
> >
> > Reviewing old patches that are still outstanding as part of the queue
> > review in patchwork. Hopefully we catch up to the point where I'm not
> > reviewing year old patches in the queue. However, some of these patches
> > are interesting and valuable so I'm reviving them to review potential
> > solutions.
> >
> > In scripts/gen-libc-modules.awk we have this code:
> >  21   if (name == "ld")
> >  22     name = "rtld"
> >
> > This means we are already handling this processing in other places. A
> > clean solution needs to consider:
> >
> > scripts/abi-version.awk (no changes, should just use rtld)
> > scripts/gen-libc-modules.awk (ld vs rtld)
> > shlib-versions (ld=...)
> >
> > It feels like we need to refactor from the top just use rtld everywhere
> > we accidentally used ld as our identifier.
>
> Since LD_SO is defined in lib-names.h, change ld.so to rtld.so requires
> scripts/lib-names.awk change.   It is a much bigger and messy change.
>

We change all internal usages to rtld by

diff --git a/elf/dl-compat.c b/elf/dl-compat.c
index 05c986a8be..6691ad1cc9 100644
--- a/elf/dl-compat.c
+++ b/elf/dl-compat.c
@@ -22,7 +22,7 @@
 /* The GLIBC_2.35 symbol version is present naturally for later ports.
    Use OTHER_SHLIB_COMPAT because the module is called rtld, but the
    ABI version uses ld.  */
-#if OTHER_SHLIB_COMPAT (ld, GLIBC_2_0, GLIBC_2_35)
+#if OTHER_SHLIB_COMPAT (rtld, GLIBC_2_0, GLIBC_2_35)
 void
 attribute_compat_text_section
 __attribute_used__
@@ -30,6 +30,6 @@ __rtld_version_placeholder_1 (void)
 {
 }

-compat_symbol (ld, __rtld_version_placeholder_1,
+compat_symbol (rtld, __rtld_version_placeholder_1,
                __rtld_version_placeholder, GLIBC_2_34);
 #endif
diff --git a/scripts/abi-versions.awk b/scripts/abi-versions.awk
index c369793459..5d229b2977 100644
--- a/scripts/abi-versions.awk
+++ b/scripts/abi-versions.awk
@@ -25,6 +25,8 @@ $2 == "=" {
   gsub(/[^A-Za-z0-9_ ]/, "_");
   oldid = $1; newid = $3;

+  if (libid == "ld")
+    libid = "rtld";
   printf "#define ABI_%s_%s\tABI_%s_%s\n", libid, oldid, libid, newid;
   printf "#define VERSION_%s_%s\t%s\n", libid, oldid, new;

@@ -36,6 +38,8 @@ $2 == "=" {
   gsub(/[^A-Za-z0-9_ ]/, "_");
   versid = $1;

+  if (libid == "ld")
+    libid = "rtld";
   printf "#define ABI_%s_%s\t%d\t/* support %s */\n", libid, versid, ++n, vers;
   printf "#define VERSION_%s_%s\t%s\n", libid, versid, vers;
   next;



-- 
H.J.

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-06 19:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02  4:29 [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132] H.J. Lu via Libc-alpha
2021-08-02  4:29 ` [PATCH 2/2] ld.so: Hide _r_debug to support DT_DEBUG [BZ #28130] H.J. Lu via Libc-alpha
2021-08-02 13:29   ` Andreas Schwab
2021-08-02 20:43     ` H.J. Lu via Libc-alpha
2021-08-02 21:19     ` Florian Weimer via Libc-alpha
2021-08-02 21:46       ` H.J. Lu via Libc-alpha
2021-08-02 23:06         ` H.J. Lu via Libc-alpha
2022-10-06 16:38 ` [PATCH 1/2] Map ABI/VERSION of rtld to ABI/VERSION of ld [BZ #28132] Carlos O'Donell via Libc-alpha
2022-10-06 18:46   ` H.J. Lu via Libc-alpha
2022-10-06 19:52     ` H.J. Lu via Libc-alpha

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 read-only IMAP folder(s) and NNTP newsgroup(s).