[libc-commits] [libc] [libc] support PIE relocations (PR #78993)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Jan 22 07:35:13 PST 2024


================
@@ -94,18 +97,26 @@ static ThreadAttributes main_thread_attrib;
     }
   }
 
+  ptrdiff_t base = 0;
   app.tls.size = 0;
+  Elf64_Phdr *tls_phdr = nullptr;
+
   for (uintptr_t i = 0; i < program_hdr_count; ++i) {
-    Elf64_Phdr *phdr = program_hdr_table + i;
-    if (phdr->p_type != PT_TLS)
-      continue;
-    // TODO: p_vaddr value has to be adjusted for static-pie executables.
-    app.tls.address = phdr->p_vaddr;
-    app.tls.size = phdr->p_memsz;
-    app.tls.init_size = phdr->p_filesz;
-    app.tls.align = phdr->p_align;
+    auto &phdr = program_hdr_table[i];
----------------
jhuber6 wrote:

Nit, explicit type is always better.

https://github.com/llvm/llvm-project/pull/78993


More information about the libc-commits mailing list