TLS support in tinyCC is absolutely not ready: - segment register not select in load and store - no relocation added for computing offset of per-thread symbol - no support for TLS-specific relocations - no program header added as per Drepper document about TLS This reverts commit 1c4afd13501f07a673aed5f130166f2ee0f30927.
Unified · Split
| @@ -447,7 +447,6 @@ typedef struct · 446 unmodified lines | ||
| 447 | 447 | #define STT_SECTION 3 /* Symbol associated with a section */ |
| 448 | 448 | #define STT_FILE 4 /* Symbol's name is file name */ |
| 449 | 449 | #define STT_NUM 5 /* Number of defined types. */ |
| 450 | −#define STT_TLS 6 /* Symbol is a thread-local data object */ | |
| 451 | 450 | #define STT_GNU_IFUNC 10 /* Symbol is a indirect code object */ |
| 452 | 451 | #define STT_LOOS 11 /* Start of OS-specific */ |
| 453 | 452 | #define STT_HIOS 12 /* End of OS-specific */ |
| @@ -556,8 +555,7 @@ typedef struct · 102 unmodified lines | ||
| 556 | 555 | #define PT_NOTE 4 /* Auxiliary information */ |
| 557 | 556 | #define PT_SHLIB 5 /* Reserved */ |
| 558 | 557 | #define PT_PHDR 6 /* Entry for header table itself */ |
| 559 | −#define PT_TLS 7 /* Thread-local program segment */ | |
| 560 | −#define PT_NUM 8 /* Number of defined types. */ | |
| 558 | +#define PT_NUM 7 /* Number of defined types. */ | |
| 561 | 559 | #define PT_LOOS 0x60000000 /* Start of OS-specific */ |
| 562 | 560 | #define PT_HIOS 0x6fffffff /* End of OS-specific */ |
| 563 | 561 | #define PT_LOPROC 0x70000000 /* Start of processor-specific */ |
| @@ -444,10 +444,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 443 unmodified lines | ||
| 444 | 444 | } else if ((sym->type.t & VT_BTYPE) == VT_VOID) { |
| 445 | 445 | sym_type = STT_NOTYPE; |
| 446 | 446 | } else { |
| 447 | − if (section && section->sh_flags & SHF_TLS) | |
| 448 | − sym_type = STT_TLS; | |
| 449 | − else | |
| 450 | − sym_type = STT_OBJECT; | |
| 447 | + sym_type = STT_OBJECT; | |
| 451 | 448 | } |
| 452 | 449 | |
| 453 | 450 | if (sym->type.t & VT_STATIC) |
| @@ -1543,7 +1543,6 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1542 unmodified lines | ||
| 1543 | 1543 | int fd, mode, ret; |
| 1544 | 1544 | int *section_order; |
| 1545 | 1545 | int shnum, i, phnum, file_offset, offset, size, j, sh_order_index, k; |
| 1546 | − int have_tls_section = 0; | |
| 1547 | 1546 | long long tmp; |
| 1548 | 1547 | addr_t addr; |
| 1549 | 1548 | Section *strsec, *s; |
| @@ -1862,11 +1861,6 @@ static int elf_output_file(TCCState *s1, const char *filename) · 312 unmodified lines | ||
| 1862 | 1861 | /* we output all sections if debug or object file */ |
| 1863 | 1862 | s->sh_size = s->data_offset; |
| 1864 | 1863 | } |
| 1865 | − /* if tls section we'll need to add one segment */ | |
| 1866 | − if (s->sh_flags & SHF_TLS) { | |
| 1867 | − have_tls_section = 1; | |
| 1868 | − phnum++; | |
| 1869 | − } | |
| 1870 | 1864 | } |
| 1871 | 1865 | |
| 1872 | 1866 | /* allocate program segment headers */ |
| @@ -1910,16 +1904,12 @@ static int elf_output_file(TCCState *s1, const char *filename) · 37 unmodified lines | ||
| 1910 | 1904 | if (interp) |
| 1911 | 1905 | ph += 1 + HAVE_PHDR; |
| 1912 | 1906 | |
| 1913 | − for(j = 0; j < 2 + have_tls_section; j++) { | |
| 1914 | − if (j != 2) | |
| 1915 | − ph->p_type = PT_LOAD; | |
| 1916 | − else | |
| 1917 | − ph->p_type = PT_TLS; | |
| 1918 | − ph->p_flags = PF_R; | |
| 1907 | + for(j = 0; j < 2; j++) { | |
| 1908 | + ph->p_type = PT_LOAD; | |
| 1919 | 1909 | if (j == 0) |
| 1920 | − ph->p_flags |= PF_X; | |
| 1921 | − else if (j == 1) | |
| 1922 | − ph->p_flags |= PF_W; | |
| 1910 | + ph->p_flags = PF_R | PF_X; | |
| 1911 | + else | |
| 1912 | + ph->p_flags = PF_R | PF_W; | |
| 1923 | 1913 | ph->p_align = s1->section_align; |
| 1924 | 1914 | |
| 1925 | 1915 | /* we do the following ordering: interp, symbol tables, |
| @@ -1930,15 +1920,12 @@ static int elf_output_file(TCCState *s1, const char *filename) · 4 unmodified lines | ||
| 1930 | 1920 | s = s1->sections[i]; |
| 1931 | 1921 | /* compute if section should be included */ |
| 1932 | 1922 | if (j == 0) { |
| 1933 | − if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE | SHF_TLS)) != | |
| 1923 | + if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE)) != | |
| 1934 | 1924 | SHF_ALLOC) |
| 1935 | 1925 | continue; |
| 1936 | − } else if (j == 1) { | |
| 1937 | − if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE | SHF_TLS)) != | |
| 1938 | − (SHF_ALLOC | SHF_WRITE)) | |
| 1939 | − continue; | |
| 1940 | 1926 | } else { |
| 1941 | − if ((s->sh_flags & SHF_TLS) != SHF_TLS) | |
| 1927 | + if ((s->sh_flags & (SHF_ALLOC | SHF_WRITE)) != | |
| 1928 | + (SHF_ALLOC | SHF_WRITE)) | |
| 1942 | 1929 | continue; |
| 1943 | 1930 | } |
| 1944 | 1931 | if (s == interp) { |
| @@ -31,7 +31,6 @@ · 30 unmodified lines | ||
| 31 | 31 | ST_DATA int rsym, anon_sym, ind, loc; |
| 32 | 32 | |
| 33 | 33 | ST_DATA Section *text_section, *data_section, *bss_section; /* predefined sections */ |
| 34 | −ST_DATA Section *tdata_section, *tbss_section; /* thread-local storage sections */ | |
| 35 | 34 | ST_DATA Section *cur_text_section; /* current section where function code is generated */ |
| 36 | 35 | #ifdef CONFIG_TCC_ASM |
| 37 | 36 | ST_DATA Section *last_text_section; /* to handle .previous asm directive */ |
| @@ -3093,10 +3092,6 @@ static int parse_btype(CType *type, AttributeDef *ad) · 3055 unmodified lines | ||
| 3093 | 3092 | t |= VT_INLINE; |
| 3094 | 3093 | next(); |
| 3095 | 3094 | break; |
| 3096 | − case TOK_THREAD: | |
| 3097 | − t |= VT_TLS; | |
| 3098 | − next(); | |
| 3099 | − break; | |
| 3100 | 3095 | |
| 3101 | 3096 | /* GNUC attribute */ |
| 3102 | 3097 | case TOK_ATTRIBUTE1: |
| @@ -5500,26 +5495,10 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r, · 2397 unmodified lines | ||
| 5500 | 5495 | /* allocate symbol in corresponding section */ |
| 5501 | 5496 | sec = ad->section; |
| 5502 | 5497 | if (!sec) { |
| 5503 | − if (has_init) { | |
| 5504 | − if (type->t & VT_TLS) { | |
| 5505 | − if (!tdata_section) | |
| 5506 | − tdata_section = new_section(tcc_state, ".tdata", | |
| 5507 | − SHT_PROGBITS, | |
| 5508 | − SHF_ALLOC | SHF_WRITE | SHF_TLS); | |
| 5509 | − sec = tdata_section; | |
| 5510 | − } else | |
| 5511 | − sec = data_section; | |
| 5512 | − } | |
| 5513 | − else if (tcc_state->nocommon) { | |
| 5514 | − if (type->t & VT_TLS) { | |
| 5515 | − if (!tbss_section) | |
| 5516 | − tbss_section = new_section(tcc_state, ".tbss", | |
| 5517 | − SHT_NOBITS, | |
| 5518 | − SHF_ALLOC | SHF_WRITE | SHF_TLS); | |
| 5519 | − sec = tbss_section; | |
| 5520 | − } else | |
| 5521 | − sec = bss_section; | |
| 5522 | − } | |
| 5498 | + if (has_init) | |
| 5499 | + sec = data_section; | |
| 5500 | + else if (tcc_state->nocommon) | |
| 5501 | + sec = bss_section; | |
| 5523 | 5502 | } |
| 5524 | 5503 | if (sec) { |
| 5525 | 5504 | data_offset = sec->data_offset; |
| @@ -10,7 +10,6 @@ · 9 unmodified lines | ||
| 10 | 10 | DEF(TOK_FOR, "for") |
| 11 | 11 | DEF(TOK_EXTERN, "extern") |
| 12 | 12 | DEF(TOK_STATIC, "static") |
| 13 | − DEF(TOK_THREAD, "__thread") | |
| 14 | 13 | DEF(TOK_UNSIGNED, "unsigned") |
| 15 | 14 | DEF(TOK_GOTO, "goto") |
| 16 | 15 | DEF(TOK_DO, "do") |