You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clang could generate right code but gcc generates absolute reference:
movq %gs:a, %rax
It seems that modifier 'P' is not compatible with PIE in gcc, so I try to use modifier 'a'
and it can generate right code. But modifier 'a' leads to compilation error in clang.
My question is why the generated code of modifier 'P' is different between gcc and clang?
Which one is right?
Thanks.
The text was updated successfully, but these errors were encountered:
I had looked up the documentation before. Regarding the 'P' modifier, it states that it "Prints the raw symbol name if used for a constant". If I understand correctly, it should generate an absolute reference. I have tested it by compiling with both -fPIE and -fno-PIE, but it seems to have no impact. So, GCC always generates an absolute reference, whereas CLANG always generates a RIP-relative reference, regardless of -fPIE being used or not.
I think the documentation is not clear enough for the user.
Additionally, I was unable to find an explanation for the 'a' modifier, even in the source code of gcc. Furthermore, it appears that the 'p' modifier is also not supported in CLANG.
I think that the documentation may be insufficient for users to fully understand the behavior of these modifiers. :(
Clang could generate right code but gcc generates absolute reference:
movq %gs:a, %rax
It seems that modifier 'P' is not compatible with PIE in gcc, so I try to use modifier 'a'
and it can generate right code. But modifier 'a' leads to compilation error in clang.
My question is why the generated code of modifier 'P' is different between gcc and clang?
Which one is right?
GCC version: 9.3.0
Clang version: 15.0.7
The output assembly code of following code is different between gcc and clang with
-c -O2 -fPIE
:The expected assembly code should be like this:
Clang could generate right code but gcc generates absolute reference:
It seems that modifier
'P'
is not compatible withPIE
in gcc, so I try to use modifier'a'
and it can generate right code. But modifier
'a'
leads to compilation error in clang.My question is why the generated code of modifier 'P' is different between gcc and clang?
Which one is right?
Thanks.
The text was updated successfully, but these errors were encountered: