[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Feature request: _Thread_local (and a possible bug)
From: |
Robert Clausecker |
Subject: |
Re: [Tinycc-devel] Feature request: _Thread_local (and a possible bug) |
Date: |
Wed, 30 Oct 2013 19:40:10 +0100 |
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:address@hidden,%eax
ret
.globl set_x
set_x: movl %edi,%fs:address@hidden
ret
.globl x_addr
x_addr: movq %fs:0,%rax
addq address@hidden,%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
- Re: [Tinycc-devel] Feature request: _Thread_local (and a possible bug),
Robert Clausecker <=