History

ARM: allow jumps > 32MB on -run

This is needed to reach tinycc's PLT from the compiled program.

Daniel Glöckner committed 16 years ago

Commit 741841d1 parent a64727b3 files · +19 −3Browse files

Unified · Split

3 files
  1. tcc.h +1 −1
  2. tccelf.c +16 −0
  3. tccrun.c +2 −2
tcc.h+1−1
@@ -547,7 +547,7 @@ struct TCCState { · 546 unmodified lines
547#endif547#endif
548 548
549#ifndef TCC_TARGET_PE549#ifndef TCC_TARGET_PE
550#ifdef TCC_TARGET_X86_64550#if defined TCC_TARGET_X86_64 || defined TCC_TARGET_ARM
551 /* write PLT and GOT here */551 /* write PLT and GOT here */
552 char *runtime_plt_and_got;552 char *runtime_plt_and_got;
553 unsigned int runtime_plt_and_got_offset;553 unsigned int runtime_plt_and_got_offset;
tccelf.c+16−0
@@ -504,6 +504,17 @@ static uplong add_got_table(TCCState *s1, uplong val) · 503 unmodified lines
504 *p = val;504 *p = val;
505 return (uplong)p;505 return (uplong)p;
506}506}
507#elif defined TCC_TARGET_ARM
508#define JMP_TABLE_ENTRY_SIZE 8
509static int add_jmp_table(TCCState *s1, int val)
510{
511 uint32_t *p = (uint32_t *)(s1->runtime_plt_and_got + s1->runtime_plt_and_got_offset);
512 s1->runtime_plt_and_got_offset += JMP_TABLE_ENTRY_SIZE;
513 /* ldr pc, [pc, #-4] */
514 p[0] = 0xE51FF004;
515 p[1] = val;
516 return (int)p;
517}
507#endif518#endif
508#endif519#endif
509 520
@@ -611,6 +622,11 @@ ST_FUNC void relocate_section(TCCState *s1, Section *s) · 101 unmodified lines
611 x -= 0x1000000;622 x -= 0x1000000;
612 x *= 4;623 x *= 4;
613 x += val - addr;624 x += val - addr;
625#ifndef TCC_TARGET_PE
626 if((x & 3) != 0 || x >= 0x4000000 || x < -0x4000000)
627 if (s1->output_type == TCC_OUTPUT_MEMORY)
628 x += add_jmp_table(s1, val) - val; /* add veneer */
629#endif
614 if((x & 3) != 0 || x >= 0x4000000 || x < -0x4000000)630 if((x & 3) != 0 || x >= 0x4000000 || x < -0x4000000)
615 error("can't relocate value at %x",addr);631 error("can't relocate value at %x",addr);
616 x >>= 2;632 x >>= 2;
tccrun.c+2−2
@@ -150,7 +150,7 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr) · 149 unmodified lines
150 if (s1->nb_errors)150 if (s1->nb_errors)
151 return -1;151 return -1;
152 152
153#if defined TCC_TARGET_X86_64 && !defined TCC_TARGET_PE153#if (defined TCC_TARGET_X86_64 || defined TCC_TARGET_ARM) && !defined TCC_TARGET_PE
154 s1->runtime_plt_and_got_offset = 0;154 s1->runtime_plt_and_got_offset = 0;
155 s1->runtime_plt_and_got = (char *)(mem + offset);155 s1->runtime_plt_and_got = (char *)(mem + offset);
156 /* double the size of the buffer for got and plt entries156 /* double the size of the buffer for got and plt entries
@@ -184,7 +184,7 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr) · 27 unmodified lines
184 set_pages_executable(ptr, length);184 set_pages_executable(ptr, length);
185 }185 }
186 186
187#if defined TCC_TARGET_X86_64 && !defined TCC_TARGET_PE187#if (defined TCC_TARGET_X86_64 || defined TCC_TARGET_ARM) && !defined TCC_TARGET_PE
188 set_pages_executable(s1->runtime_plt_and_got,188 set_pages_executable(s1->runtime_plt_and_got,
189 s1->runtime_plt_and_got_offset);189 s1->runtime_plt_and_got_offset);
190#endif190#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t