Hello Thomas,
Thank you for your effort. Unfortunately, the change breaks tcc.
When I compile the following file:
__thread int x;
I get the error
*** Error in `tcc': malloc(): memory corruption: 0x0000000001d74c40 ***
and tcc does not terminate afterwards.
Also, I have the impression that the commit you made does not implement
__thread correctly. The following C code should compile to the assembly
further below on x86-64:
__thread int x;
int get_x(void) {
return x;
}
void set_x(int a) {
x = a;
}
int *x_addr(void) {
return &x;
}
/* --- */
.text
.globl get_x
get_x: movl %fs:x@tpoff,%eax
ret
.globl set_x
set_x: movl %edi,%fs:x@tpoff
ret
.globl x_addr
x_addr: movq %fs:0,%rax
addq $x@tpoff,%rax
ret
.globl x
.section .tbss
.type x,@object
.size x, 4
x: .zero 4
I see nothing in the patch you made that indicates any special access
conventions to thread-local variables (such as %fs-relative
instructions). It might very well be possible that I missed that, but I
can't test because tcc does not compile the code at all on my machine.
Yours, Robert Clausecker
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel