- tccpe.c: commit "tidy support for helper function" created STT_NOTYPE symbols and hence relied on ad-hoc detection which didn't work for x86_64 (as reported by Christian Jullien) - tccgen.c: However to be more safe the helper symbols are now made STT_FUNC anyway (via new VT_ASM_FUNC).
Unified · Split
| @@ -138,7 +138,7 @@ DEF-i386-win32 = -DTCC_TARGET_PE -DTCC_TARGET_I386 · 137 unmodified lines | |||
| 138 | DEF-x86_64-win32= -DTCC_TARGET_PE -DTCC_TARGET_X86_64 | 138 | DEF-x86_64-win32= -DTCC_TARGET_PE -DTCC_TARGET_X86_64 |
| 139 | DEF-x86_64-osx = -DTCC_TARGET_MACHO -DTCC_TARGET_X86_64 | 139 | DEF-x86_64-osx = -DTCC_TARGET_MACHO -DTCC_TARGET_X86_64 |
| 140 | DEF-arm-wince = -DTCC_TARGET_PE -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP -DTCC_ARM_HARDFLOAT | 140 | DEF-arm-wince = -DTCC_TARGET_PE -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP -DTCC_ARM_HARDFLOAT |
| 141 | DEF-arm64 = -DTCC_TARGET_ARM64 -Wno-format | 141 | DEF-arm64 = -DTCC_TARGET_ARM64 |
| 142 | DEF-c67 = -DTCC_TARGET_C67 -w # disable warnigs | 142 | DEF-c67 = -DTCC_TARGET_C67 -w # disable warnigs |
| 143 | DEF-arm-fpa = -DTCC_TARGET_ARM | 143 | DEF-arm-fpa = -DTCC_TARGET_ARM |
| 144 | DEF-arm-fpa-ld = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12 | 144 | DEF-arm-fpa-ld = -DTCC_TARGET_ARM -DLDOUBLE_SIZE=12 |
| @@ -587,7 +587,7 @@ ST_FUNC void load(int r, SValue *sv) · 586 unmodified lines | |||
| 587 | return; | 587 | return; |
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | printf("load(%x, (%x, %x, %llx))\n", r, svtt, sv->r, (long long)svcul); | 590 | printf("load(%x, (%x, %x, %lx))\n", r, svtt, sv->r, (long)svcul); |
| 591 | assert(0); | 591 | assert(0); |
| 592 | } | 592 | } |
| 593 | 593 | ||
| @@ -639,7 +639,7 @@ ST_FUNC void store(int r, SValue *sv) · 45 unmodified lines | |||
| 639 | return; | 639 | return; |
| 640 | } | 640 | } |
| 641 | 641 | ||
| 642 | printf("store(%x, (%x, %x, %llx))\n", r, svtt, sv->r, (long long)svcul); | 642 | printf("store(%x, (%x, %x, %lx))\n", r, svtt, sv->r, (long)svcul); |
| 643 | assert(0); | 643 | assert(0); |
| 644 | } | 644 | } |
| 645 | 645 | ||
| @@ -116,7 +116,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 115 unmodified lines | |||
| 116 | uint64_t got = s1->got->sh_addr; | 116 | uint64_t got = s1->got->sh_addr; |
| 117 | uint64_t off = (got >> 12) - (plt >> 12); | 117 | uint64_t off = (got >> 12) - (plt >> 12); |
| 118 | if ((off + ((uint32_t)1 << 20)) >> 21) | 118 | if ((off + ((uint32_t)1 << 20)) >> 21) |
| 119 | tcc_error("Failed relocating PLT (off=0x%lx, got=0x%lx, plt=0x%lx)", off, got, plt); | 119 | tcc_error("Failed relocating PLT (off=0x%lx, got=0x%lx, plt=0x%lx)", (long)off, (long)got, (long)plt); |
| 120 | write32le(p, 0xa9bf7bf0); // stp x16,x30,[sp,#-16]! | 120 | write32le(p, 0xa9bf7bf0); // stp x16,x30,[sp,#-16]! |
| 121 | write32le(p + 4, (0x90000010 | // adrp x16,... | 121 | write32le(p + 4, (0x90000010 | // adrp x16,... |
| 122 | (off & 0x1ffffc) << 3 | (off & 3) << 29)); | 122 | (off & 0x1ffffc) << 3 | (off & 3) << 29)); |
| @@ -134,7 +134,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 11 unmodified lines | |||
| 134 | uint64_t addr = got + read64le(p); | 134 | uint64_t addr = got + read64le(p); |
| 135 | uint64_t off = (addr >> 12) - (pc >> 12); | 135 | uint64_t off = (addr >> 12) - (pc >> 12); |
| 136 | if ((off + ((uint32_t)1 << 20)) >> 21) | 136 | if ((off + ((uint32_t)1 << 20)) >> 21) |
| 137 | tcc_error("Failed relocating PLT (off=0x%lx, addr=0x%lx, pc=0x%lx)", off, addr, pc); | 137 | tcc_error("Failed relocating PLT (off=0x%lx, addr=0x%lx, pc=0x%lx)", (long)off, (long)addr, (long)pc); |
| 138 | write32le(p, (0x90000010 | // adrp x16,... | 138 | write32le(p, (0x90000010 | // adrp x16,... |
| 139 | (off & 0x1ffffc) << 3 | (off & 3) << 29)); | 139 | (off & 0x1ffffc) << 3 | (off & 3) << 29)); |
| 140 | write32le(p + 4, (0xf9400211 | // ldr x17,[x16,#...] | 140 | write32le(p + 4, (0xf9400211 | // ldr x17,[x16,#...] |
| @@ -239,7 +239,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t · 98 unmodified lines | |||
| 239 | #endif | 239 | #endif |
| 240 | if (((val - addr) + ((uint64_t)1 << 27)) & ~(uint64_t)0xffffffc) | 240 | if (((val - addr) + ((uint64_t)1 << 27)) & ~(uint64_t)0xffffffc) |
| 241 | tcc_error("R_AARCH64_(JUMP|CALL)26 relocation failed" | 241 | tcc_error("R_AARCH64_(JUMP|CALL)26 relocation failed" |
| 242 | " (val=%lx, addr=%lx)", val, addr); | 242 | " (val=%lx, addr=%lx)", (long)val, (long)addr); |
| 243 | write32le(ptr, (0x14000000 | | 243 | write32le(ptr, (0x14000000 | |
| 244 | (uint32_t)(type == R_AARCH64_CALL26) << 31 | | 244 | (uint32_t)(type == R_AARCH64_CALL26) << 31 | |
| 245 | ((val - addr) >> 2 & 0x3ffffff))); | 245 | ((val - addr) >> 2 & 0x3ffffff))); |
| @@ -166,7 +166,7 @@ static int load_symofs(int r, SValue *sv, int forstore) · 165 unmodified lines | |||
| 166 | sv->c.i = 0; | 166 | sv->c.i = 0; |
| 167 | } else { | 167 | } else { |
| 168 | if (((unsigned)fc + (1 << 11)) >> 12) | 168 | if (((unsigned)fc + (1 << 11)) >> 12) |
| 169 | tcc_error("unimp: large addend for global address (0x%llx)", (long long)sv->c.i); | 169 | tcc_error("unimp: large addend for global address (0x%lx)", (long)sv->c.i); |
| 170 | greloca(cur_text_section, sv->sym, ind, | 170 | greloca(cur_text_section, sv->sym, ind, |
| 171 | R_RISCV_GOT_HI20, 0); | 171 | R_RISCV_GOT_HI20, 0); |
| 172 | doload = 1; | 172 | doload = 1; |
| @@ -188,7 +188,7 @@ static int load_symofs(int r, SValue *sv, int forstore) · 15 unmodified lines | |||
| 188 | } else if (v == VT_LOCAL || v == VT_LLOCAL) { | 188 | } else if (v == VT_LOCAL || v == VT_LLOCAL) { |
| 189 | rr = 8; // s0 | 189 | rr = 8; // s0 |
| 190 | if (fc != sv->c.i) | 190 | if (fc != sv->c.i) |
| 191 | tcc_error("unimp: store(giant local off) (0x%llx)", (long long)sv->c.i); | 191 | tcc_error("unimp: store(giant local off) (0x%lx)", (long)sv->c.i); |
| 192 | if (((unsigned)fc + (1 << 11)) >> 12) { | 192 | if (((unsigned)fc + (1 << 11)) >> 12) { |
| 193 | rr = is_ireg(r) ? ireg(r) : 5; // t0 | 193 | rr = is_ireg(r) ? ireg(r) : 5; // t0 |
| 194 | o(0x37 | (rr << 7) | ((0x800 + fc) & 0xfffff000)); //lui RR, upper(fc) | 194 | o(0x37 | (rr << 7) | ((0x800 + fc) & 0xfffff000)); //lui RR, upper(fc) |
| @@ -127,7 +127,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 126 unmodified lines | |||
| 127 | uint64_t got = s1->got->sh_addr; | 127 | uint64_t got = s1->got->sh_addr; |
| 128 | uint64_t off = (got - plt + 0x800) >> 12; | 128 | uint64_t off = (got - plt + 0x800) >> 12; |
| 129 | if ((off + ((uint32_t)1 << 20)) >> 21) | 129 | if ((off + ((uint32_t)1 << 20)) >> 21) |
| 130 | tcc_error("Failed relocating PLT (off=0x%lx, got=0x%lx, plt=0x%lx)", off, got, plt); | 130 | tcc_error("Failed relocating PLT (off=0x%lx, got=0x%lx, plt=0x%lx)", (long)off, (long)got, (long)plt); |
| 131 | write32le(p, 0x397 | (off << 12)); // auipc t2, %pcrel_hi(got) | 131 | write32le(p, 0x397 | (off << 12)); // auipc t2, %pcrel_hi(got) |
| 132 | write32le(p + 4, 0x41c30333); // sub t1, t1, t3 | 132 | write32le(p + 4, 0x41c30333); // sub t1, t1, t3 |
| 133 | write32le(p + 8, 0x0003be03 // ld t3, %pcrel_lo(got)(t2) | 133 | write32le(p + 8, 0x0003be03 // ld t3, %pcrel_lo(got)(t2) |
| @@ -144,7 +144,7 @@ ST_FUNC void relocate_plt(TCCState *s1) · 10 unmodified lines | |||
| 144 | uint64_t addr = got + read64le(p); | 144 | uint64_t addr = got + read64le(p); |
| 145 | uint64_t off = (addr - pc + 0x800) >> 12; | 145 | uint64_t off = (addr - pc + 0x800) >> 12; |
| 146 | if ((off + ((uint32_t)1 << 20)) >> 21) | 146 | if ((off + ((uint32_t)1 << 20)) >> 21) |
| 147 | tcc_error("Failed relocating PLT (off=0x%lx, addr=0x%lx, pc=0x%lx)", off, addr, pc); | 147 | tcc_error("Failed relocating PLT (off=0x%lx, addr=0x%lx, pc=0x%lx)", (long)off, (long)addr, (long)pc); |
| 148 | write32le(p, 0xe17 | (off << 12)); // auipc t3, %pcrel_hi(func@got) | 148 | write32le(p, 0xe17 | (off << 12)); // auipc t3, %pcrel_hi(func@got) |
| 149 | write32le(p + 4, 0x000e3e03 // ld t3, %pcrel_lo(func@got)(t3) | 149 | write32le(p + 4, 0x000e3e03 // ld t3, %pcrel_lo(func@got)(t3) |
| 150 | | (((addr - pc) & 0xfff) << 20)); | 150 | | (((addr - pc) & 0xfff) << 20)); |
| @@ -177,7 +177,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 26 unmodified lines | |||
| 177 | off64 = val - addr; | 177 | off64 = val - addr; |
| 178 | if ((off64 + (1 << 12)) & ~(uint64_t)0x1ffe) | 178 | if ((off64 + (1 << 12)) & ~(uint64_t)0x1ffe) |
| 179 | tcc_error("R_RISCV_BRANCH relocation failed" | 179 | tcc_error("R_RISCV_BRANCH relocation failed" |
| 180 | " (val=%lx, addr=%lx)", val, addr); | 180 | " (val=%lx, addr=%lx)", (long)val, (long)addr); |
| 181 | off32 = off64 >> 1; | 181 | off32 = off64 >> 1; |
| 182 | write32le(ptr, (read32le(ptr) & ~0xfe000f80) | 182 | write32le(ptr, (read32le(ptr) & ~0xfe000f80) |
| 183 | | ((off32 & 0x800) << 20) | 183 | | ((off32 & 0x800) << 20) |
| @@ -189,7 +189,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 5 unmodified lines | |||
| 189 | off64 = val - addr; | 189 | off64 = val - addr; |
| 190 | if ((off64 + (1 << 21)) & ~(((uint64_t)1 << 22) - 2)) | 190 | if ((off64 + (1 << 21)) & ~(((uint64_t)1 << 22) - 2)) |
| 191 | tcc_error("R_RISCV_JAL relocation failed" | 191 | tcc_error("R_RISCV_JAL relocation failed" |
| 192 | " (val=%lx, addr=%lx)", val, addr); | 192 | " (val=%lx, addr=%lx)", (long)val, (long)addr); |
| 193 | off32 = off64; | 193 | off32 = off64; |
| 194 | write32le(ptr, (read32le(ptr) & 0xfff) | 194 | write32le(ptr, (read32le(ptr) & 0xfff) |
| 195 | | (((off32 >> 12) & 0xff) << 12) | 195 | | (((off32 >> 12) & 0xff) << 12) |
| @@ -206,12 +206,12 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 10 unmodified lines | |||
| 206 | return; | 206 | return; |
| 207 | case R_RISCV_PCREL_HI20: | 207 | case R_RISCV_PCREL_HI20: |
| 208 | #ifdef DEBUG_RELOC | 208 | #ifdef DEBUG_RELOC |
| 209 | printf("PCREL_HI20: val=%lx addr=%lx\n", val, addr); | 209 | printf("PCREL_HI20: val=%lx addr=%lx\n", (long)val, (long)addr); |
| 210 | #endif | 210 | #endif |
| 211 | off64 = (int64_t)(val - addr + 0x800) >> 12; | 211 | off64 = (int64_t)(val - addr + 0x800) >> 12; |
| 212 | if ((off64 + ((uint64_t)1 << 20)) >> 21) | 212 | if ((off64 + ((uint64_t)1 << 20)) >> 21) |
| 213 | tcc_error("R_RISCV_PCREL_HI20 relocation failed: off=%lx cond=%lx sym=%s", | 213 | tcc_error("R_RISCV_PCREL_HI20 relocation failed: off=%lx cond=%lx sym=%s", |
| 214 | off64, ((int64_t)(off64 + ((uint64_t)1 << 20)) >> 21), | 214 | (long)off64, (long)((int64_t)(off64 + ((uint64_t)1 << 20)) >> 21), |
| 215 | symtab_section->link->data + sym->st_name); | 215 | symtab_section->link->data + sym->st_name); |
| 216 | write32le(ptr, (read32le(ptr) & 0xfff) | 216 | write32le(ptr, (read32le(ptr) & 0xfff) |
| 217 | | ((off64 & 0xfffff) << 12)); | 217 | | ((off64 & 0xfffff) << 12)); |
| @@ -230,7 +230,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 12 unmodified lines | |||
| 230 | return; | 230 | return; |
| 231 | case R_RISCV_PCREL_LO12_I: | 231 | case R_RISCV_PCREL_LO12_I: |
| 232 | #ifdef DEBUG_RELOC | 232 | #ifdef DEBUG_RELOC |
| 233 | printf("PCREL_LO12_I: val=%lx addr=%lx\n", val, addr); | 233 | printf("PCREL_LO12_I: val=%lx addr=%lx\n", (long)val, (long)addr); |
| 234 | #endif | 234 | #endif |
| 235 | if (val != last_hi.addr) | 235 | if (val != last_hi.addr) |
| 236 | tcc_error("unsupported hi/lo pcrel reloc scheme"); | 236 | tcc_error("unsupported hi/lo pcrel reloc scheme"); |
| @@ -254,7 +254,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 17 unmodified lines | |||
| 254 | off64 = (val - addr); | 254 | off64 = (val - addr); |
| 255 | if ((off64 + (1 << 8)) & ~(uint64_t)0x1fe) | 255 | if ((off64 + (1 << 8)) & ~(uint64_t)0x1fe) |
| 256 | tcc_error("R_RISCV_RVC_BRANCH relocation failed" | 256 | tcc_error("R_RISCV_RVC_BRANCH relocation failed" |
| 257 | " (val=%lx, addr=%lx)", val, addr); | 257 | " (val=%lx, addr=%lx)", (long)val, (long)addr); |
| 258 | off32 = off64; | 258 | off32 = off64; |
| 259 | write16le(ptr, (read16le(ptr) & 0xe383) | 259 | write16le(ptr, (read16le(ptr) & 0xe383) |
| 260 | | (((off32 >> 5) & 1) << 2) | 260 | | (((off32 >> 5) & 1) << 2) |
| @@ -267,7 +267,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 6 unmodified lines | |||
| 267 | off64 = (val - addr); | 267 | off64 = (val - addr); |
| 268 | if ((off64 + (1 << 11)) & ~(uint64_t)0xffe) | 268 | if ((off64 + (1 << 11)) & ~(uint64_t)0xffe) |
| 269 | tcc_error("R_RISCV_RVC_BRANCH relocation failed" | 269 | tcc_error("R_RISCV_RVC_BRANCH relocation failed" |
| 270 | " (val=%lx, addr=%lx)", val, addr); | 270 | " (val=%lx, addr=%lx)", (long)val, (long)addr); |
| 271 | off32 = off64; | 271 | off32 = off64; |
| 272 | write16le(ptr, (read16le(ptr) & 0xe003) | 272 | write16le(ptr, (read16le(ptr) & 0xe003) |
| 273 | | (((off32 >> 5) & 1) << 2) | 273 | | (((off32 >> 5) & 1) << 2) |
| @@ -1011,7 +1011,8 @@ struct filespec { · 1010 unmodified lines | |||
| 1011 | #define VT_TYPE (~(VT_STORAGE|VT_STRUCT_MASK)) | 1011 | #define VT_TYPE (~(VT_STORAGE|VT_STRUCT_MASK)) |
| 1012 | 1012 | ||
| 1013 | /* symbol was created by tccasm.c first */ | 1013 | /* symbol was created by tccasm.c first */ |
| 1014 | #define VT_ASM (VT_VOID | VT_UNSIGNED) | 1014 | #define VT_ASM (VT_VOID | 1 << VT_STRUCT_SHIFT) |
| 1015 | #define VT_ASM_FUNC (VT_ASM | 2 << VT_STRUCT_SHIFT) | ||
| 1015 | #define IS_ASM_SYM(sym) (((sym)->type.t & (VT_BTYPE | VT_ASM)) == VT_ASM) | 1016 | #define IS_ASM_SYM(sym) (((sym)->type.t & (VT_BTYPE | VT_ASM)) == VT_ASM) |
| 1016 | 1017 | ||
| 1017 | /* general: set/get the pseudo-bitfield value for bit-mask M */ | 1018 | /* general: set/get the pseudo-bitfield value for bit-mask M */ |
| @@ -1251,15 +1252,6 @@ ST_FUNC void cstr_free(CString *cstr); · 233 unmodified lines | |||
| 1251 | ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...) PRINTF_LIKE(2,3); | 1252 | ST_FUNC int cstr_printf(CString *cs, const char *fmt, ...) PRINTF_LIKE(2,3); |
| 1252 | ST_FUNC void cstr_reset(CString *cstr); | 1253 | ST_FUNC void cstr_reset(CString *cstr); |
| 1253 | 1254 | ||
| 1254 | ST_INLN void sym_free(Sym *sym); | ||
| 1255 | ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, int c); | ||
| 1256 | ST_FUNC Sym *sym_find2(Sym *s, int v); | ||
| 1257 | ST_FUNC Sym *sym_push(int v, CType *type, int r, int c); | ||
| 1258 | ST_FUNC void sym_pop(Sym **ptop, Sym *b, int keep); | ||
| 1259 | ST_INLN Sym *struct_find(int v); | ||
| 1260 | ST_INLN Sym *sym_find(int v); | ||
| 1261 | ST_FUNC Sym *global_identifier_push(int v, int t, int c); | ||
| 1262 | |||
| 1263 | ST_FUNC void tcc_open_bf(TCCState *s1, const char *filename, int initlen); | 1255 | ST_FUNC void tcc_open_bf(TCCState *s1, const char *filename, int initlen); |
| 1264 | ST_FUNC int tcc_open(TCCState *s1, const char *filename); | 1256 | ST_FUNC int tcc_open(TCCState *s1, const char *filename); |
| 1265 | ST_FUNC void tcc_close(void); | 1257 | ST_FUNC void tcc_close(void); |
| @@ -1433,25 +1425,44 @@ ST_INLN int is_float(int t); · 167 unmodified lines | |||
| 1433 | ST_FUNC int ieee_finite(double d); | 1425 | ST_FUNC int ieee_finite(double d); |
| 1434 | ST_FUNC int exact_log2p1(int i); | 1426 | ST_FUNC int exact_log2p1(int i); |
| 1435 | ST_FUNC void test_lvalue(void); | 1427 | ST_FUNC void test_lvalue(void); |
| 1436 | ST_FUNC void vpushi(int v); | 1428 | |
| 1437 | ST_FUNC ElfSym *elfsym(Sym *); | 1429 | ST_FUNC ElfSym *elfsym(Sym *); |
| 1438 | ST_FUNC void update_storage(Sym *sym); | 1430 | ST_FUNC void update_storage(Sym *sym); |
| 1431 | ST_FUNC void put_extern_sym2(Sym *sym, int sh_num, addr_t value, unsigned long size, int can_add_underscore); | ||
| 1432 | ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size); | ||
| 1433 | #if PTR_SIZE == 4 | ||
| 1434 | ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type); | ||
| 1435 | #endif | ||
| 1436 | ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type, addr_t addend); | ||
| 1437 | |||
| 1438 | ST_INLN void sym_free(Sym *sym); | ||
| 1439 | ST_FUNC Sym *sym_push(int v, CType *type, int r, int c); | ||
| 1440 | ST_FUNC void sym_pop(Sym **ptop, Sym *b, int keep); | ||
| 1441 | ST_FUNC Sym *sym_push2(Sym **ps, int v, int t, int c); | ||
| 1442 | ST_FUNC Sym *sym_find2(Sym *s, int v); | ||
| 1443 | ST_INLN Sym *sym_find(int v); | ||
| 1444 | ST_INLN Sym *struct_find(int v); | ||
| 1445 | |||
| 1446 | ST_FUNC Sym *global_identifier_push(int v, int t, int c); | ||
| 1439 | ST_FUNC Sym *external_global_sym(int v, CType *type); | 1447 | ST_FUNC Sym *external_global_sym(int v, CType *type); |
| 1440 | ST_FUNC Sym *external_helper_sym(int v); | 1448 | ST_FUNC Sym *external_helper_sym(int v); |
| 1441 | ST_FUNC void vpush_helper_func(int v); | 1449 | ST_FUNC void vpush_helper_func(int v); |
| 1442 | ST_FUNC void vset(CType *type, int r, int v); | 1450 | ST_FUNC void vset(CType *type, int r, int v); |
| 1443 | ST_FUNC void vset_VT_CMP(int op); | 1451 | ST_FUNC void vset_VT_CMP(int op); |
| 1452 | ST_FUNC void vpushi(int v); | ||
| 1453 | ST_FUNC void vpushv(SValue *v); | ||
| 1454 | ST_FUNC void vpushsym(CType *type, Sym *sym); | ||
| 1444 | ST_FUNC void vswap(void); | 1455 | ST_FUNC void vswap(void); |
| 1445 | ST_FUNC void vrote(SValue *e, int n); | 1456 | ST_FUNC void vrote(SValue *e, int n); |
| 1446 | ST_FUNC void vrott(int n); | 1457 | ST_FUNC void vrott(int n); |
| 1447 | ST_FUNC void vrotb(int n); | 1458 | ST_FUNC void vrotb(int n); |
| 1459 | ST_FUNC void vpop(void); | ||
| 1448 | #if PTR_SIZE == 4 | 1460 | #if PTR_SIZE == 4 |
| 1449 | ST_FUNC void lexpand(void); | 1461 | ST_FUNC void lexpand(void); |
| 1450 | #endif | 1462 | #endif |
| 1451 | #ifdef TCC_TARGET_ARM | 1463 | #ifdef TCC_TARGET_ARM |
| 1452 | ST_FUNC int get_reg_ex(int rc, int rc2); | 1464 | ST_FUNC int get_reg_ex(int rc, int rc2); |
| 1453 | #endif | 1465 | #endif |
| 1454 | ST_FUNC void vpushv(SValue *v); | ||
| 1455 | ST_FUNC void save_reg(int r); | 1466 | ST_FUNC void save_reg(int r); |
| 1456 | ST_FUNC void save_reg_upstack(int r, int n); | 1467 | ST_FUNC void save_reg_upstack(int r, int n); |
| 1457 | ST_FUNC int get_reg(int rc); | 1468 | ST_FUNC int get_reg(int rc); |
| @@ -1459,7 +1470,6 @@ ST_FUNC void save_regs(int n); · 1 unmodified line | |||
| 1459 | ST_FUNC void gaddrof(void); | 1470 | ST_FUNC void gaddrof(void); |
| 1460 | ST_FUNC int gv(int rc); | 1471 | ST_FUNC int gv(int rc); |
| 1461 | ST_FUNC void gv2(int rc1, int rc2); | 1472 | ST_FUNC void gv2(int rc1, int rc2); |
| 1462 | ST_FUNC void vpop(void); | ||
| 1463 | ST_FUNC void gen_op(int op); | 1473 | ST_FUNC void gen_op(int op); |
| 1464 | ST_FUNC int type_size(CType *type, int *a); | 1474 | ST_FUNC int type_size(CType *type, int *a); |
| 1465 | ST_FUNC void mk_pointer(CType *type); | 1475 | ST_FUNC void mk_pointer(CType *type); |
| @@ -1513,13 +1523,6 @@ ST_FUNC void *section_ptr_add(Section *sec, addr_t size); · 47 unmodified lines | |||
| 1513 | ST_FUNC Section *find_section(TCCState *s1, const char *name); | 1523 | ST_FUNC Section *find_section(TCCState *s1, const char *name); |
| 1514 | ST_FUNC Section *new_symtab(TCCState *s1, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags); | 1524 | ST_FUNC Section *new_symtab(TCCState *s1, const char *symtab_name, int sh_type, int sh_flags, const char *strtab_name, const char *hash_name, int hash_sh_flags); |
| 1515 | 1525 | ||
| 1516 | ST_FUNC void put_extern_sym2(Sym *sym, int sh_num, addr_t value, unsigned long size, int can_add_underscore); | ||
| 1517 | ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size); | ||
| 1518 | #if PTR_SIZE == 4 | ||
| 1519 | ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type); | ||
| 1520 | #endif | ||
| 1521 | ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type, addr_t addend); | ||
| 1522 | |||
| 1523 | ST_FUNC int put_elf_str(Section *s, const char *sym); | 1526 | ST_FUNC int put_elf_str(Section *s, const char *sym); |
| 1524 | ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name); | 1527 | ST_FUNC int put_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name); |
| 1525 | ST_FUNC int set_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name); | 1528 | ST_FUNC int set_elf_sym(Section *s, addr_t value, unsigned long size, int info, int other, int shndx, const char *name); |
| @@ -921,6 +921,8 @@ ST_FUNC void put_extern_sym2(Sym *sym, int sh_num, · 920 unmodified lines | |||
| 921 | sym_type = STT_FUNC; | 921 | sym_type = STT_FUNC; |
| 922 | } else if ((t & VT_BTYPE) == VT_VOID) { | 922 | } else if ((t & VT_BTYPE) == VT_VOID) { |
| 923 | sym_type = STT_NOTYPE; | 923 | sym_type = STT_NOTYPE; |
| 924 | if ((t & (VT_BTYPE|VT_ASM_FUNC)) == VT_ASM_FUNC) | ||
| 925 | sym_type = STT_FUNC; | ||
| 924 | } else { | 926 | } else { |
| 925 | sym_type = STT_OBJECT; | 927 | sym_type = STT_OBJECT; |
| 926 | } | 928 | } |
| @@ -1440,7 +1442,7 @@ static void gen_test_zero(int op) · 513 unmodified lines | |||
| 1440 | 1442 | ||
| 1441 | /* ------------------------------------------------------------------------- */ | 1443 | /* ------------------------------------------------------------------------- */ |
| 1442 | /* push a symbol value of TYPE */ | 1444 | /* push a symbol value of TYPE */ |
| 1443 | static inline void vpushsym(CType *type, Sym *sym) | 1445 | ST_FUNC void vpushsym(CType *type, Sym *sym) |
| 1444 | { | 1446 | { |
| 1445 | CValue cval; | 1447 | CValue cval; |
| 1446 | cval.i = 0; | 1448 | cval.i = 0; |
| @@ -1489,7 +1491,7 @@ ST_FUNC Sym *external_global_sym(int v, CType *type) · 42 unmodified lines | |||
| 1489 | This avoids type conflicts if the symbol is used from C too */ | 1491 | This avoids type conflicts if the symbol is used from C too */ |
| 1490 | ST_FUNC Sym *external_helper_sym(int v) | 1492 | ST_FUNC Sym *external_helper_sym(int v) |
| 1491 | { | 1493 | { |
| 1492 | CType ct = { VT_ASM, NULL }; | 1494 | CType ct = { VT_ASM_FUNC, NULL }; |
| 1493 | return external_global_sym(v, &ct); | 1495 | return external_global_sym(v, &ct); |
| 1494 | } | 1496 | } |
| 1495 | 1497 | ||
| @@ -384,8 +384,8 @@ static int check_symbols(TCCState *s1, struct macho *mo) · 383 unmodified lines | |||
| 384 | unsigned bind = ELFW(ST_BIND)(sym->st_info); | 384 | unsigned bind = ELFW(ST_BIND)(sym->st_info); |
| 385 | unsigned vis = ELFW(ST_VISIBILITY)(sym->st_other); | 385 | unsigned vis = ELFW(ST_VISIBILITY)(sym->st_other); |
| 386 | 386 | ||
| 387 | dprintf("%4d (%4d): %09llx %4d %4d %4d %3d %s\n", | 387 | dprintf("%4d (%4d): %09lx %4d %4d %4d %3d %s\n", |
| 388 | sym_index, elf_index, sym->st_value, | 388 | sym_index, elf_index, (long)sym->st_value, |
| 389 | type, bind, vis, sym->st_shndx, name); | 389 | type, bind, vis, sym->st_shndx, name); |
| 390 | if (bind == STB_LOCAL) { | 390 | if (bind == STB_LOCAL) { |
| 391 | if (mo->ilocal == -1) | 391 | if (mo->ilocal == -1) |
| @@ -680,14 +680,14 @@ static void collect_sections(TCCState *s1, struct macho *mo) · 288 unmodified lines | |||
| 680 | for (s = mo->sk_to_sect[sk].s; s; s = s->prev) { | 680 | for (s = mo->sk_to_sect[sk].s; s; s = s->prev) { |
| 681 | al = s->sh_addralign; | 681 | al = s->sh_addralign; |
| 682 | curaddr = (curaddr + al - 1) & -al; | 682 | curaddr = (curaddr + al - 1) & -al; |
| 683 | dprintf("curaddr now 0x%llx\n", curaddr); | 683 | dprintf("curaddr now 0x%lx\n", (long)curaddr); |
| 684 | s->sh_addr = curaddr; | 684 | s->sh_addr = curaddr; |
| 685 | curaddr += s->sh_size; | 685 | curaddr += s->sh_size; |
| 686 | if (s->sh_type != SHT_NOBITS) { | 686 | if (s->sh_type != SHT_NOBITS) { |
| 687 | fileofs = (fileofs + al - 1) & -al; | 687 | fileofs = (fileofs + al - 1) & -al; |
| 688 | s->sh_offset = fileofs; | 688 | s->sh_offset = fileofs; |
| 689 | fileofs += s->sh_size; | 689 | fileofs += s->sh_size; |
| 690 | dprintf("fileofs now %lld\n", fileofs); | 690 | dprintf("fileofs now %ld\n", (long)fileofs); |
| 691 | } | 691 | } |
| 692 | if (sec) | 692 | if (sec) |
| 693 | mo->elfsectomacho[s->sh_num] = numsec; | 693 | mo->elfsectomacho[s->sh_num] = numsec; |
| @@ -699,7 +699,7 @@ static void collect_sections(TCCState *s1, struct macho *mo) · 5 unmodified lines | |||
| 699 | for (s = mo->sk_to_sect[sk].s; s; s = s->prev) { | 699 | for (s = mo->sk_to_sect[sk].s; s; s = s->prev) { |
| 700 | int type = s->sh_type; | 700 | int type = s->sh_type; |
| 701 | int flags = s->sh_flags; | 701 | int flags = s->sh_flags; |
| 702 | printf("%d section %-16s %-10s %09llx %04x %02d %s,%s,%s\n", | 702 | printf("%d section %-16s %-10s %09lx %04x %02d %s,%s,%s\n", |
| 703 | sk, | 703 | sk, |
| 704 | s->name, | 704 | s->name, |
| 705 | type == SHT_PROGBITS ? "progbits" : | 705 | type == SHT_PROGBITS ? "progbits" : |
| @@ -709,7 +709,7 @@ static void collect_sections(TCCState *s1, struct macho *mo) · 3 unmodified lines | |||
| 709 | type == SHT_INIT_ARRAY ? "init" : | 709 | type == SHT_INIT_ARRAY ? "init" : |
| 710 | type == SHT_FINI_ARRAY ? "fini" : | 710 | type == SHT_FINI_ARRAY ? "fini" : |
| 711 | type == SHT_RELX ? "rel" : "???", | 711 | type == SHT_RELX ? "rel" : "???", |
| 712 | s->sh_addr, | 712 | (long)s->sh_addr, |
| 713 | (unsigned)s->data_offset, | 713 | (unsigned)s->data_offset, |
| 714 | s->sh_addralign, | 714 | s->sh_addralign, |
| 715 | flags & SHF_ALLOC ? "alloc" : "", | 715 | flags & SHF_ALLOC ? "alloc" : "", |
| @@ -966,8 +966,8 @@ ST_FUNC int macho_load_dll(TCCState *s1, int fd, const char *filename, int lev) · 250 unmodified lines | |||
| 966 | //for (i = 0; i < nsyms; i++) { | 966 | //for (i = 0; i < nsyms; i++) { |
| 967 | for (i = iextdef; i < iextdef + nextdef; i++) { | 967 | for (i = iextdef; i < iextdef + nextdef; i++) { |
| 968 | struct nlist_64 *sym = symtab + i; | 968 | struct nlist_64 *sym = symtab + i; |
| 969 | dprintf("%5d: %3d %3d 0x%04x 0x%016llx %s\n", | 969 | dprintf("%5d: %3d %3d 0x%04x 0x%016lx %s\n", |
| 970 | i, sym->n_type, sym->n_sect, sym->n_desc, sym->n_value, | 970 | i, sym->n_type, sym->n_sect, sym->n_desc, (long)sym->n_value, |
| 971 | strtab + sym->n_strx); | 971 | strtab + sym->n_strx); |
| 972 | set_elf_sym(s1->dynsymtab_section, 0, 0, | 972 | set_elf_sym(s1->dynsymtab_section, 0, 0, |
| 973 | ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), | 973 | ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), |
| @@ -35,6 +35,7 @@ · 34 unmodified lines | |||
| 35 | # define REL_TYPE_DIRECT R_X86_64_64 | 35 | # define REL_TYPE_DIRECT R_X86_64_64 |
| 36 | # define R_XXX_THUNKFIX R_X86_64_PC32 | 36 | # define R_XXX_THUNKFIX R_X86_64_PC32 |
| 37 | # define R_XXX_RELATIVE R_X86_64_RELATIVE | 37 | # define R_XXX_RELATIVE R_X86_64_RELATIVE |
| 38 | # define R_XXX_FUNCCALL R_X86_64_PC32 | ||
| 38 | # define IMAGE_FILE_MACHINE 0x8664 | 39 | # define IMAGE_FILE_MACHINE 0x8664 |
| 39 | # define RSRC_RELTYPE 3 | 40 | # define RSRC_RELTYPE 3 |
| 40 | 41 | ||
| @@ -44,6 +45,8 @@ · 3 unmodified lines | |||
| 44 | # define REL_TYPE_DIRECT R_ARM_ABS32 | 45 | # define REL_TYPE_DIRECT R_ARM_ABS32 |
| 45 | # define R_XXX_THUNKFIX R_ARM_ABS32 | 46 | # define R_XXX_THUNKFIX R_ARM_ABS32 |
| 46 | # define R_XXX_RELATIVE R_ARM_RELATIVE | 47 | # define R_XXX_RELATIVE R_ARM_RELATIVE |
| 48 | # define R_XXX_FUNCCALL R_ARM_PC24 | ||
| 49 | # define R_XXX_FUNCCALL2 R_ARM_ABS32 | ||
| 47 | # define IMAGE_FILE_MACHINE 0x01C0 | 50 | # define IMAGE_FILE_MACHINE 0x01C0 |
| 48 | # define RSRC_RELTYPE 7 /* ??? (not tested) */ | 51 | # define RSRC_RELTYPE 7 /* ??? (not tested) */ |
| 49 | 52 | ||
| @@ -53,6 +56,7 @@ · 3 unmodified lines | |||
| 53 | # define REL_TYPE_DIRECT R_386_32 | 56 | # define REL_TYPE_DIRECT R_386_32 |
| 54 | # define R_XXX_THUNKFIX R_386_32 | 57 | # define R_XXX_THUNKFIX R_386_32 |
| 55 | # define R_XXX_RELATIVE R_386_RELATIVE | 58 | # define R_XXX_RELATIVE R_386_RELATIVE |
| 59 | # define R_XXX_FUNCCALL R_386_PC32 | ||
| 56 | # define IMAGE_FILE_MACHINE 0x014C | 60 | # define IMAGE_FILE_MACHINE 0x014C |
| 57 | # define RSRC_RELTYPE 7 /* DIR32NB */ | 61 | # define RSRC_RELTYPE 7 /* DIR32NB */ |
| 58 | 62 | ||
| @@ -1217,13 +1221,21 @@ static int pe_isafunc(TCCState *s1, int sym_index) · 1158 unmodified lines | |||
| 1217 | { | 1221 | { |
| 1218 | Section *sr = text_section->reloc; | 1222 | Section *sr = text_section->reloc; |
| 1219 | ElfW_Rel *rel, *rel_end; | 1223 | ElfW_Rel *rel, *rel_end; |
| 1220 | Elf32_Word info = ELF32_R_INFO(sym_index, R_386_PC32); | 1224 | ElfW(Addr)info = ELFW(R_INFO)(sym_index, R_XXX_FUNCCALL); |
| 1225 | #ifdef R_XXX_FUNCCALL2 | ||
| 1226 | ElfW(Addr)info2 = ELFW(R_INFO)(sym_index, R_XXX_FUNCCALL2); | ||
| 1227 | #endif | ||
| 1221 | if (!sr) | 1228 | if (!sr) |
| 1222 | return 0; | 1229 | return 0; |
| 1223 | rel_end = (ElfW_Rel *)(sr->data + sr->data_offset); | 1230 | rel_end = (ElfW_Rel *)(sr->data + sr->data_offset); |
| 1224 | for (rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) | 1231 | for (rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) { |
| 1225 | if (rel->r_info == info) | 1232 | if (rel->r_info == info) |
| 1226 | return 1; | 1233 | return 1; |
| 1234 | #ifdef R_XXX_FUNCCALL2 | ||
| 1235 | if (rel->r_info == info2) | ||
| 1236 | return 1; | ||
| 1237 | #endif | ||
| 1238 | } | ||
| 1227 | return 0; | 1239 | return 0; |
| 1228 | } | 1240 | } |
| 1229 | 1241 | ||