tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Do any flags avoid internal error: relocation failed?


From: Harry Yan
Subject: Re: [Tinycc-devel] Do any flags avoid internal error: relocation failed?
Date: Mon, 26 Dec 2022 07:48:58 +0800 (CST)

Hi Levo,

The error messages might come from the following source files:

arm64-gen.c:    // results in "R_AARCH64_ADR_PREL_PG_HI21 relocation failed" whe
n
arm64-link.c:                tcc_error("R_AARCH64_ADR_PREL_PG_HI21 relocation fa
iled");
arm64-link.c:                tcc_error("R_AARCH64_(JUMP|CALL)26 relocation faile
d"
arm64-link.c:                tcc_error("R_AARCH64_ADR_GOT_PAGE relocation failed
");
x86_64-link.c:                tcc_error("internal error: relocation failed");


For example, in x86_64-link.c:

225         case R_X86_64_PLT32:
226             /* fallthrough: val already holds the PLT slot address */
227
228         plt32pc32:
229         {
230             long long diff;
231             diff = (long long)val - addr;
232             if (diff < -2147483648LL || diff > 2147483647LL) {
233                 tcc_error("internal error: relocation failed");
234             }
235             add32le(ptr, diff);
236         }
237             break;
238
239         case R_X86_64_PLTOFF64:
240             add64le(ptr, val - s1->got->sh_addr + rel->r_addend);
241             break;
242
243         case R_X86_64_PC64:
244             if (s1->output_type == TCC_OUTPUT_DLL) {
245                 /* DLL relocation */
246                 esym_index = s1->sym_attrs[sym_index].dyn_index;
247                 if (esym_index) {

Where the variables #val and #addr is defined as:

173 void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, add
    r_t addr, addr_t val)

I haven't looked into it, but it seems to be a overflow or something, which 
might get fixed by using a larger type.

Hope it helps,
Harry




At 2022-12-24 13:37:53, "Levo D" <maynotreply@mail9fcb1a.bolinlang.com> wrote:
>I'm playing around with tcc and seeing how many lines it can run per second
>
>I tried a silly 2 million lined c file and it failed with "tcc: error: 
>internal error: relocation failed". I tried using -c thinking I should run a 
>tcc process for each of my cores however that doesn't increase the amount of 
>code I can compile. Writing "tcc -nostdlib *.o" I get the same internal error. 
>I was trying to find how much work I'll need to provide it to actually use a 
>full second.
>
>I really don't need a solution, I'm just fooling around. If there's a flag I 
>can use to avoid this error I'll want to try it. I tried looking through 
>https://man.cx/tcc(1) and didn't see anything obvious
>
>
>
>_______________________________________________
>Tinycc-devel mailing list
>Tinycc-devel@nongnu.org
>https://lists.nongnu.org/mailman/listinfo/tinycc-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]