Hi Segher, Following is more information that I can collect. Please let me know if you need anything else. Thank you very much for your help. Regards, Hon ===================================================================== + this is part of the content of cdev.c, from which the error happened ... ... struct static_key_false test; int qdma_cdev_init(void) { if (static_branch_unlikely(&test)) { printk("test...\n"); } return 0; } void qdma_cdev_cleanup(void) { } ... + static_branch_unlikely is defined as followed from /lib/modules/`uname -r`/build/include/linux/jump_label.h : #define static_branch_unlikely(x) \ ({ \ bool branch; \ if (__builtin_types_compatible_p(typeof(*x), struct static_key_true)) \ branch = arch_static_branch_jump(&(x)->key, false); \ else if (__builtin_types_compatible_p(typeof(*x), struct static_key_false)) \ branch = arch_static_branch(&(x)->key, false); \ else \ branch = ____wrong_branch_error(); \ unlikely(branch); \ }) + the error is related to arch_static_branch_jump() which is defined from /lib/modules/`uname -r`/build/arch/x86/include/asm/jump_label.h as followed: static __always_inline bool arch_static_branch(struct static_key *key, bool branch) { asm_volatile_goto("1:" ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" ".pushsection __jump_table, \"aw\" \n\t" _ASM_ALIGN "\n\t" _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t" ".popsection \n\t" : : "i" (key), "i" (branch) : : l_yes); return false; l_yes: return true; } + The code compiled successfully in kernel mode with followed command: + make V=1 clean + make V=1 + The code failed to compile when I try to compile into user space mode with the followed command: + make -f Makefile.user clean + make -f Makefile.user + Note that the difference between gcc command line between the 2 modes are: + kernel: .... -fno-PIE ... -mcmodel=kernel ... + user space: .... -fPIC ... < removed > ... + Another interesting note is: + if I remove -fPIC from user space gcc command, then the code compile successfully. However -fPIC is the must for my project. -----Original Message----- From: Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx> Sent: Friday, September 10, 2021 11:36 AM To: HON LUU <hon@xxxxxxxxxxxxxxxx> Cc: gcc-help@xxxxxxxxxxx Subject: Re: gcc question On Fri, Sep 10, 2021 at 05:58:07PM +0000, HON LUU wrote: > Hi Segher, > > I wonder if you have any issues to reproduce the problem. > Attached is the tar ball of stand alone module, which duplicate the issue. > There is a README file, should be straightforward to duplicate the issue. > You need to show the full code of the asm_volatile_goto, and the declarations of everything used in its operands, for us to get a handle on what is going on here. Bonus points if you manage to make a stand- alone compilable testcase that shows the problem. If you write up a good email with all the necessary info, you will get an answer (and a good answer!) much quicker. I do not particularly feel like doing all the work here. Sorry. Segher