[PATCH] elf: Support at least 32-byte alignment in static dlopen

Florian Weimer fweimer@redhat.com
Fri Jul 10 20:26:33 GMT 2020


Otherwise loading a dynamically linked libc with rseq support fails,
as result of the __rseq_abi TLS variable, which has an alignment
of 32 bytes.

---
 csu/libc-tls.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/csu/libc-tls.c b/csu/libc-tls.c
index 06e76bd395..3f1655f264 100644
--- a/csu/libc-tls.c
+++ b/csu/libc-tls.c
@@ -112,6 +112,12 @@ __libc_setup_tls (void)
   size_t tcb_offset;
   const ElfW(Phdr) *phdr;
 
+  /* libc.so with rseq has TLS with 32-byte alignment.  Static dlopen
+     requires at least 32-byte alignment as well, otherwise loading
+     libc.so will always fail.  */
+  if (max_align < 32)
+    max_align = 32;
+
   struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded;
 
   /* Look through the TLS segment if there is any.  */



More information about the Libc-alpha mailing list