glibc/sysdeps
Aurelien Jarno fe20bb1d60 ARM: fix kernel assisted atomics with GCC 8 (bug 24034)
The pre-ARMv7 CPUs are missing atomic compare and exchange and/or
barrier instructions. Therefore those are implemented using kernel
assistance, calling a kernel function at a specific address, and passing
the arguments in the r0 to r4 registers. This is done by specifying
registers for local variables. The a_ptr variable is placed in the r2
register and declared with __typeof (mem). According to the GCC
documentation on local register variables, if mem is a constant pointer,
the compiler may substitute the variable with its initializer in asm
statements, which may cause the corresponding operand to appear in a
different register.

This happens in __libc_start_main with the pointer to the thread counter
for static binaries (but not the shared ones):

  # ifdef SHARED
        unsigned int *ptr = __libc_pthread_functions.ptr_nthreads;
  #  ifdef PTR_DEMANGLE
        PTR_DEMANGLE (ptr);
  #  endif
  # else
        extern unsigned int __nptl_nthreads __attribute ((weak));
        unsigned int *const ptr = &__nptl_nthreads;
  # endif

This causes static binaries using threads to crash when the GNU libc is
built with GCC 8 and most notably tst-cancel21-static.

To fix that, use the same trick than for the volatile qualifier,
defining a_ptr as a union.

Changelog:
	[BZ #24034]
	* sysdeps/unix/sysv/linux/arm/atomic-machine.h
	(__arm_assisted_compare_and_exchange_val_32_acq): Use uint32_t rather
	than __typeof (...) for the a_ptr variable.
2019-01-02 18:21:18 +01:00
..
aarch64 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
alpha Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
arm Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
csky Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
generic Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
gnu Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
hppa Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
htl Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
hurd Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
i386 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
ia64 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
ieee754 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
init_array Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
m68k Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
mach Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
microblaze Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
mips Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
nios2 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
nptl Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
posix Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
powerpc Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
pthread Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
riscv Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
s390 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
sh Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
sparc Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
unix ARM: fix kernel assisted atomics with GCC 8 (bug 24034) 2019-01-02 18:21:18 +01:00
wordsize-32 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
wordsize-64 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
x86 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00
x86_64 Update copyright dates with scripts/update-copyrights. 2019-01-01 00:11:28 +00:00