]> Git Repo - uclibc-ng.git/commitdiff
static pie: fix building static PDE
authorMax Filippov <[email protected]>
Thu, 15 Sep 2022 19:30:50 +0000 (12:30 -0700)
committerWaldemar Brodkorb <[email protected]>
Wed, 21 Sep 2022 08:35:40 +0000 (10:35 +0200)
When uclibc is built with static PIE support the _dl_load_base variable
shared between the libc-tls.c and reloc_static_pie.c creates the
dependency that requires linking reloc_static_pie.o into static
position-dependent executables resulting in the following build errors:
  gcc -static test.c -o test
  ...ld:
  ...usr/lib/libc.a(reloc_static_pie.os):(.text+0x0):
undefined reference to `_DYNAMIC'

Move _dl_load_base definition to libc-tls.c to resolve this dependency
and fix static PDE build.

Signed-off-by: Max Filippov <[email protected]>
libc/misc/internals/reloc_static_pie.c
libpthread/nptl/sysdeps/generic/libc-tls.c

index c0027de6fe066d598853fd515313d5d0ea5ecee4..ce42cb9b30dff5a013d815e64767b696a0048375 100644 (file)
@@ -25,7 +25,7 @@
 #include <dl-startup.h>
 #endif
 
-ElfW(Addr) _dl_load_base = NULL;
+extern ElfW(Addr) _dl_load_base;
 
 void
 reloc_static_pie (ElfW(Addr) load_addr);
@@ -107,4 +107,4 @@ reloc_static_pie(ElfW(Addr) load_addr)
 #endif
     }
     _dl_load_base = load_addr;
-}
\ No newline at end of file
+}
index 54f3cb0c72b57a74a0949e14d8f2168c5b37e4c8..7cfe9ac1a85cd6e05797c0c052bace095595ce01 100644 (file)
@@ -117,6 +117,10 @@ init_static_tls (size_t memsz, size_t align)
   GL(dl_tls_static_nelem) = GL(dl_tls_max_dtv_idx);
 }
 
+#if !defined(__FDPIC__) && !defined(SHARED) && defined(STATIC_PIE)
+ElfW(Addr) _dl_load_base;
+#endif
+
 void __libc_setup_tls (size_t tcbsize, size_t tcbalign);
 void
 __libc_setup_tls (size_t tcbsize, size_t tcbalign)
@@ -143,8 +147,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
 #else
          initimage = (void *) phdr->p_vaddr;
 #if !defined(SHARED) && defined(STATIC_PIE)
-    extern ElfW(Addr) _dl_load_base;
-    initimage += _dl_load_base;
+         initimage += _dl_load_base;
 #endif
 #endif
          align = phdr->p_align;
This page took 0.028488 seconds and 4 git commands to generate.