diff --git a/tcc.h b/tcc.h index 5033b19..1688a0c 100644 --- a/tcc.h +++ b/tcc.h @@ -712,12 +712,6 @@ struct TCCState { void *write_mem; unsigned long mem_size; # endif -# if !defined TCC_TARGET_PE && (0) - /* write PLT and GOT here */ - char *runtime_plt_and_got; - unsigned runtime_plt_and_got_offset; -# define TCC_HAS_RUNTIME_PLTGOT -# endif #endif /* used by main and tcc_parse_args only */ diff --git a/tccelf.c b/tccelf.c index 6f63f83..6955847 100644 --- a/tccelf.c +++ b/tccelf.c @@ -476,42 +476,6 @@ ST_FUNC void relocate_syms(TCCState *s1, int do_resolve) } } -#ifdef TCC_HAS_RUNTIME_PLTGOT -#ifdef TCC_TARGET_X86_64 -#define JMP_TABLE_ENTRY_SIZE 14 -static addr_t add_jmp_table(TCCState *s1, addr_t val) -{ - char *p = s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset; - s1->runtime_plt_and_got_offset += JMP_TABLE_ENTRY_SIZE; - /* jmp *0x0(%rip) */ - p[0] = 0xff; - p[1] = 0x25; - *(int *)(p + 2) = 0; - *(addr_t *)(p + 6) = val; - return (addr_t)p; -} - -static addr_t add_got_table(TCCState *s1, addr_t val) -{ - addr_t *p = (addr_t *)(s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset); - s1->runtime_plt_and_got_offset += sizeof(addr_t); - *p = val; - return (addr_t)p; -} -#elif defined TCC_TARGET_ARM -#define JMP_TABLE_ENTRY_SIZE 8 -static addr_t add_jmp_table(TCCState *s1, int val) -{ - uint32_t *p = (uint32_t *)(s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset); - s1->runtime_plt_and_got_offset += JMP_TABLE_ENTRY_SIZE; - /* ldr pc, [pc, #-4] */ - p[0] = 0xE51FF004; - p[1] = val; - return (addr_t)p; -} -#endif -#endif /* def TCC_HAS_RUNTIME_PLTGOT */ - /* relocate a given section (CPU dependent) by applying the relocations in the associated relocation section */ ST_FUNC void relocate_section(TCCState *s1, Section *s) @@ -627,15 +591,6 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) #endif h = x & 2; th_ko = (x & 3) && (!blx_avail || !is_call); -#ifdef TCC_HAS_RUNTIME_PLTGOT - if (s1->output_type == TCC_OUTPUT_MEMORY) { - if (th_ko || x >= 0x2000000 || x < -0x2000000) { - x += add_jmp_table(s1, val) - val; /* add veneer */ - th_ko = (x & 3) && (!blx_avail || !is_call); - is_thumb = 0; /* Veneer uses ARM instructions */ - } - } -#endif if (th_ko || x >= 0x2000000 || x < -0x2000000) tcc_error("can't relocate value at %x,%d",addr, type); x >>= 2; @@ -878,17 +833,7 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) long long diff; diff = (long long)val - addr; if (diff <= -2147483647 || diff > 2147483647) { -#ifdef TCC_HAS_RUNTIME_PLTGOT - /* XXX: naive support for over 32bit jump */ - if (s1->output_type == TCC_OUTPUT_MEMORY) { - val = (add_jmp_table(s1, val - rel->r_addend) + - rel->r_addend); - diff = val - addr; - } -#endif - if (diff <= -2147483647 || diff > 2147483647) { - tcc_error("internal error: relocation failed"); - } + tcc_error("internal error: relocation failed"); } *(int *)ptr += diff; } @@ -899,13 +844,6 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) *(addr_t *)ptr = val - rel->r_addend; break; case R_X86_64_GOTPCREL: -#ifdef TCC_HAS_RUNTIME_PLTGOT - if (s1->output_type == TCC_OUTPUT_MEMORY) { - val = add_got_table(s1, val - rel->r_addend) + rel->r_addend; - *(int *)ptr += val - addr; - break; - } -#endif *(int *)ptr += (s1->got->sh_addr - addr + s1->sym_attrs[sym_index].got_offset - 4); break; diff --git a/tccrun.c b/tccrun.c index 2876ab7..52a74b3 100644 --- a/tccrun.c +++ b/tccrun.c @@ -180,14 +180,6 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr) if (s1->nb_errors) return -1; -#ifdef TCC_HAS_RUNTIME_PLTGOT - s1->runtime_plt_and_got_offset = 0; - s1->runtime_plt_and_got = (char *)(mem + offset); - /* double the size of the buffer for got and plt entries - XXX: calculate exact size for them? */ - offset *= 2; -#endif - if (0 == mem) return offset; @@ -215,11 +207,6 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr) set_pages_executable(ptr, length); } -#ifdef TCC_HAS_RUNTIME_PLTGOT - set_pages_executable(s1->runtime_plt_and_got, - s1->runtime_plt_and_got_offset); -#endif - #ifdef _WIN64 win64_add_function_table(s1); #endif