Skip to content

Commit

Permalink
wip: LoongArch: Enforce using GOT for address per-CPU objects
Browse files Browse the repository at this point in the history
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
  • Loading branch information
xry111 committed Jul 29, 2022
1 parent 60ba323 commit c1d5d70
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions arch/loongarch/include/asm/percpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
#include <asm/cmpxchg.h>
#include <asm/loongarch.h>

/* Force GCC to load the "address" (offset from r21 in fact) of per-CPU
variables via GOT. PC-relative address obviously won't work. */
#ifdef MODULE
# if __has_attribute(__addr_global__)
# define PER_CPU_ATTRIBUTES __attribute__((__addr_global__))
# else
# error "per-CPU variable in module is currently broken"
# endif /* __addr_global__ */
#endif /* MODULE */

/* Use r21 for fast access */
register unsigned long __my_cpu_offset __asm__("$r21");

Expand Down

0 comments on commit c1d5d70

Please sign in to comment.