[RFC,v6,18/20] Add DT_GNU_FLAGS_1/DF_GNU_1_UNIQUE dynamic section+flag to glibc DSOs

Message ID 20201215184500.25915-19-vivek@collabora.com
State Superseded
Headers
Series Implementation of RTLD_SHARED for dlmopen |

Commit Message

Vivek Dasmohapatra Dec. 15, 2020, 6:44 p.m. UTC
  libc.so, libpthread.so etc should have the new unique-dso-by-default
flag set to allow dlmopen to work better (libc et al instance shared
by default when DSOs dlmopened into a new namespace).
---
 Makeconfig         | 1 +
 Makerules          | 2 +-
 iconvdata/Makefile | 1 +
 nptl/Makefile      | 2 +-
 4 files changed, 4 insertions(+), 2 deletions(-)
  

Comments

Samuel Thibault Dec. 15, 2020, 6:56 p.m. UTC | #1
Hello,

Vivek Das Mohapatra via Libc-alpha, le mar. 15 déc. 2020 18:44:58 +0000, a ecrit:
> libc.so, libpthread.so etc should have the new unique-dso-by-default
> flag set to allow dlmopen to work better (libc et al instance shared
> by default when DSOs dlmopened into a new namespace).
> ---

> diff --git a/nptl/Makefile b/nptl/Makefile
> index ddd83dfbdd..314931cbaa 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -354,7 +354,7 @@ else
>  tests-printers-libs := $(static-thread-library)
>  endif
>  
> -LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
> +LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,unique,-z,nodelete,-z,initfirst
>  
>  tests += tst-cancelx7 tst-cancelx17 tst-cleanupx4

Please also do the same in htl/Makefile

Samuel
  
Vivek Dasmohapatra Dec. 15, 2020, 11:21 p.m. UTC | #2
>> -LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
>> +LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,unique,-z,nodelete,-z,initfirst

> Please also do the same in htl/Makefile
> Samuel

Building and running tests, will send new series tomorow.
  

Patch

diff --git a/Makeconfig b/Makeconfig
index 8074613b85..6ed137e2a3 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -398,6 +398,7 @@  LDFLAGS-lib.so += -Wl,-z,now
 # Extra flags for dynamically linked non-test main programs.
 link-extra-flags += -Wl,-z,now
 endif
+LDFLAGS-lib.so += -Wl,-z,unique
 
 # Command to run after every final link (executable or shared object).
 # This is invoked with $(call after-link,...), so it should operate on
diff --git a/Makerules b/Makerules
index ef0fe67d9a..ffb4f74de0 100644
--- a/Makerules
+++ b/Makerules
@@ -635,7 +635,7 @@  build-shlib-objlist = $(build-module-helper-objlist) \
 # Don't try to use -lc when making libc.so itself.
 # Also omits crti.o and crtn.o, which we do not want
 # since we define our own `.init' section specially.
-LDFLAGS-c.so = -nostdlib -nostartfiles
+LDFLAGS-c.so = -nostdlib -nostartfiles -Wl,-z,unique
 # But we still want to link libc.so against $(libc.so-gnulib).
 LDLIBS-c.so += $(libc.so-gnulib)
 # Give libc.so an entry point and make it directly runnable itself.
diff --git a/iconvdata/Makefile b/iconvdata/Makefile
index 4ec2741cdc..121808a8fe 100644
--- a/iconvdata/Makefile
+++ b/iconvdata/Makefile
@@ -67,6 +67,7 @@  modules	:= ISO8859-1 ISO8859-2 ISO8859-3 ISO8859-4 ISO8859-5		 \
 ifeq ($(bind-now),yes)
 LDFLAGS.so += -Wl,-z,now
 endif
+LDFLAGS.so += -Wl,-z,unique
 
 modules.so := $(addsuffix .so, $(modules))
 
diff --git a/nptl/Makefile b/nptl/Makefile
index ddd83dfbdd..314931cbaa 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -354,7 +354,7 @@  else
 tests-printers-libs := $(static-thread-library)
 endif
 
-LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
+LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,unique,-z,nodelete,-z,initfirst
 
 tests += tst-cancelx7 tst-cancelx17 tst-cleanupx4