[glibc/azanella/clang] elf: Use volatile to set __rseq_size and __rseq_offset

Adhemerval Zanella azanella@sourceware.org
Tue May 10 18:30:19 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2eef58aa05788913117fb6e6f7a8d5011642e8eb

commit 2eef58aa05788913117fb6e6f7a8d5011642e8eb
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sun Apr 3 11:23:20 2022 -0300

    elf: Use volatile to set __rseq_size and __rseq_offset
    
    To avoid compiler to optimize them away.

Diff:
---
 sysdeps/nptl/dl-tls_init_tp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysdeps/nptl/dl-tls_init_tp.c b/sysdeps/nptl/dl-tls_init_tp.c
index 53fba774a5..01ff90117c 100644
--- a/sysdeps/nptl/dl-tls_init_tp.c
+++ b/sysdeps/nptl/dl-tls_init_tp.c
@@ -109,7 +109,7 @@ __tls_init_tp (void)
       {
         /* We need a writable view of the variables.  They are in
            .data.relro and are not yet write-protected.  */
-        extern unsigned int size __asm__ ("__rseq_size");
+        extern volatile unsigned int size __asm__ ("__rseq_size");
         size = sizeof (pd->rseq_area);
       }
 
@@ -119,7 +119,7 @@ __tls_init_tp (void)
        all targets support __thread_pointer, so set __rseq_offset only
        if thre rseq registration may have happened because RSEQ_SIG is
        defined.  */
-    extern ptrdiff_t offset __asm__ ("__rseq_offset");
+    extern volatile ptrdiff_t offset __asm__ ("__rseq_offset");
     offset = (char *) &pd->rseq_area - (char *) __thread_pointer ();
 #endif
   }


More information about the Glibc-cvs mailing list