bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

x86_64-gnu 14.2.0 cross-compiler -O2 removes THREAD_SETMEM in glibc sigr


From: janneke
Subject: x86_64-gnu 14.2.0 cross-compiler -O2 removes THREAD_SETMEM in glibc sigreturn.c
Date: Fri, 22 Nov 2024 17:05:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hello,

We found (<https://lists.gnu.org/archive/html/bug-hurd/2024-11/msg00143.html)
while cross-building glibc-2.39 for the 64bit Hurd, our x86_64-gnu-gcc
removes a THREAD_SETMEM from glibc's sigreturn.c, line 47:

<https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mach/hurd/x86_64/sigreturn.c;h=7a0193497dfec71633c45066f2be3fb8863320e8;hb=ef321e23c20eebc6d6fb4044425c00e6df27b05f>

    42    reply_port = THREAD_GETMEM (THREAD_SELF, reply_port);
    43    THREAD_SETMEM (THREAD_SELF, reply_port, MACH_PORT_DEAD);
    44    if (__glibc_likely (MACH_PORT_VALID (reply_port)))
    45      (void) __mach_port_mod_refs (__mach_task_self (), reply_port,
    46                                   MACH_PORT_RIGHT_RECEIVE, -1);
    47    THREAD_SETMEM (THREAD_SELF, reply_port, sc_reply_port);
    47a   asm ("nop");
    48  
    49    asm volatile (
    50                  /* Point the stack to the register dump.  */
    51                  "movq %0, %%rsp\n"
    52

When adding a "nop" (line 47a), the THREAD_SETMEM is present.

THREAD_SETMEM is defined here:

<https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mach/hurd/x86_64/tls.h;h=3d3253963b5de04d10adf93fe52c5956108e2fd4;hb=ef321e23c20eebc6d6fb4044425c00e6df27b05f#l92>

    86  # define THREAD_SELF                                                    
\
    87    (*(tcbhead_t * __seg_fs *) offsetof (tcbhead_t, tcb))
    88  /* Read member of the thread descriptor directly.  */
    89  # define THREAD_GETMEM(descr, member)                                   
\
    90    (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member))
    91  /* Write member of the thread descriptor directly.  */
    92  # define THREAD_SETMEM(descr, member, value)                            
\
    93    (*(__typeof (descr->member) __seg_fs *) offsetof (tcbhead_t, member) 
= value)

Find attached a minimized version of sigreturn.c as bug.c; and its
preprocessed versions: bug.E and using -DADD_NOP: bug-with-nop.E.

Find also their objdump -d --reloc as bug.o.d and bug-with-nop.o.d
(that's the correct one).

Compile using

--8<---------------cut here---------------start------------->8---
x86_64-pc-gnu-gcc -x c bug.E -c -fgnu89-inline -O2 -o bug.o
objdump --reloc -d bug.o > bug.o.d
x86_64-pc-gnu-gcc -x c bug-with-nop.E -c -fgnu89-inline -O2 -o bug-with-nop.o
objdump --reloc -d bug-with-nop.o > bug-with-nop.o.d
--8<---------------cut here---------------end--------------->8---

x86_64-pc-gnu-gcc was configured using

--8<---------------cut here---------------start------------->8---
configure flags: 
("CONFIG_SHELL=/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash"
 
"SHELL=/gnu/store/3jhfhxdf6v5ms10x5zmnl166dh3yhbr1-bash-minimal-5.1.16/bin/bash"
 
"--prefix=/gnu/store/bwms311pmmik24zzmwppqg0vvxz2gbip-gcc-cross-x86_64-pc-gnu-14.2.0"
 "--enable-fast-install" 
"--libdir=/gnu/store/c9vicnq7wpdqid2sdnk0drrpaklxrkd3-gcc-cross-x86_64-pc-gnu-14.2.0-lib/lib"
 
"--includedir=/gnu/store/c9vicnq7wpdqid2sdnk0drrpaklxrkd3-gcc-cross-x86_64-pc-gnu-14.2.0-lib/include"
 "--build=x86_64-unknown-linux-gnu" "--target=x86_64-pc-gnu" 
"--disable-libcilkrts" "--with-sysroot=/" 
"--with-toolexeclibdir=/gnu/store/c9vicnq7wpdqid2sdnk0drrpaklxrkd3-gcc-cross-x86_64-pc-gnu-14.2.0-lib/x86_64-pc-gnu/lib"
 "--enable-plugin" "--disable-multilib" "--with-system-zlib" 
"--disable-libstdcxx-pch" "--with-local-prefix=/no-gcc-local-prefix" 
"--with-gxx-include-dir=/gnu/store/bwms311pmmik24zzmwppqg0vvxz2gbip-gcc-cross-x86_64-pc-gnu-14.2.0/include/c++"
 
"--with-native-system-header-dir=/gnu/store/nxj04wlw32p80ybn8mi8s7kd5l65mkid-glibc-cross-x86_64-pc-gnu-2.39/include"
 "--disable-libcilkrts" "CC_FOR_TARGET=x86_64-pc-gnu-gcc" 
"CXX_FOR_TARGET=x86_64-pc-gnu-g++" "LD_FOR_TARGET=x86_64-pc-gnu-ld" 
"AR_FOR_TARGET=x86_64-pc-gnu-ar" "NM_FOR_TARGET=x86_64-pc-gnu-nm" 
"OBJDUMP_FOR_TARGET=x86_64-pc-gnu-objdump" 
"RANLIB_FOR_TARGET=x86_64-pc-gnu-ranlib" "STRIP_FOR_TARGET=x86_64-pc-gnu-strip")
--8<---------------cut here---------------end--------------->8---

full build log: 
<https://dezyne.org/janneke/hurd/bwms311pmmik24zzmwppqg0vvxz2gbip-gcc-cross-x86_64-pc-gnu-14.2.0.gz>

Greetings,
Janneke

Attachment: bug.c
Description: Binary data

Attachment: bug.E
Description: Binary data

Attachment: bug-with-nop.E
Description: Binary data

Attachment: bug.o.d
Description: Binary data

Attachment: bug-with-nop.o.d
Description: Binary data

-- 
Janneke Nieuwenhuizen <janneke@gnu.org>  | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | AvatarĀ® https://AvatarAcademy.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]