https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81863
--- Comment #2 from Arnd Bergmann <arnd at linaro dot org> --- This is a reduced test case that triggers with gcc-4.9 and higher (latest tested is 7.1.1) $ arm-linux-gnueabi-gcc-7.1.1 -mword-relocations -march=armv7-a -O2 -Wall -c test-ww_mutex.c $ objdump -dr test-ww_mutex.o | grep MOV 4c: R_ARM_MOVW_ABS_NC c 50: R_ARM_MOVT_ABS c --- int a, d, f; long b; struct ww_class { int stamp; } c; struct stress { int locks; int nlocks; }; void *e; int atomic_add_return_relaxed(int *p1) { __builtin_prefetch(p1); return a; } void atomic_long_inc_return_relaxed(int *p1) { int *v = p1; atomic_add_return_relaxed(v); } void ww_acquire_init(struct ww_class *p1) { atomic_long_inc_return_relaxed(&p1->stamp); } void ww_mutex_lock(); int *get_random_order(); void stress_inorder_work() { struct stress *g = e; int h = g->nlocks; int *i = &g->locks, *j = get_random_order(); do { int n; ww_acquire_init(&c); retry: for (n = 0; n < h; n++) ww_mutex_lock(i[j[n]]); f = n; if (d) goto retry; } while (b); }