This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug inline-asm/66631] inability to clobber segment regs makes tls problematic


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66631

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Stas Sergeev from comment #11)
> (In reply to Andrew Pinski from comment #9)
> > Clang is not GCC.  Really you should not be using the fs segment register
> > for your own use as it is part of the ABI that is the TLS segment.  Any
> > other use it of it is outside of the ABI and will break everything else. 
> > Why can't you not use fs segment?
> Alien code in place (think of wine/dosemu).

Those all have pure assembly code to handle this case.  That is they have
wrapper code which handles the first part in pure C and then pass it on to the
other code.

> 
> > Also why can't you write your segfault handler in assembly when you fixup
> > the fs segment and then call the C functions?
> In principle - yes, but in practice - looking into a source -
> too much work. It is large, and it also uses a syscalls:
> sys_prctl(ARCH_SET_FS, eflags_fs_gs.fsbase);
> Do syscalls in asm too? :(
> Of course this all is possible, but...

I don't see why you need to do the first part in assembly code and then pass it
on to C code.

> 
> Should I really resort to always using -O1 till that also break? :(
> Let me ask you from the other side: why not simply to
> allow clobber also segregs? Improvement for everyone IMHO.
> clang did that for chromium it seems - likely a jit either.
> IMHO gcc should allow writing the specific things like
> signal handlers, interrupt handlers in embedded systems,
> etc - they all have suprises and deviations from ABI, yet
> gcc usually has an extensions to cover all these needs. Why
> to suddenly change that good practice?

Or why do you need to use the fs segment when it is part of the x86 Linux ABI? 
It seems like you are outside of C/ABI at this stage and need pure assembly to
fix up your code.  Again this is outside of the x86 Linux ABI and GCC should
not handle this at all.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]