[Top][All Lists]

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

Re: [Tinycc-devel] Flushing caches before -running a program

From: grischka
Subject: Re: [Tinycc-devel] Flushing caches before -running a program
Date: Tue, 12 Mar 2013 10:43:11 +0100
User-agent: Thunderbird (Windows/20090812)

Thomas Preud'homme wrote:
Hi there,

when packaging TinyCC 0.9.26 for Debian I noticed a build failure on arm with EABI calling convention. A bit puzzled at the failure after all the testing done (this bug didn't show up on my hardware), I then started to investigate.

After some look at the code, I asked for help to fellow Debian Developers and one quickly found that the problem came from the lack of flushing of instruction and data caches before running a program in the -run mode.

+    __clear_cache(prog_main, prog_main + get_code_size(s1));

"prog_main + get_code_size(s1)" is generally not a meaningful
expression as prog_main may not be first in code.

Also this doesn't flush data caches if that is what you want (as
you wrote).  Also:

> if (s->phase)

Not a good name.  There are more than a few "phases" going on in

> return text_section->data_offset;

Why do you need an extra function to return text_section->data_offset?

I then quickly started working on a patch but I needed to know the size of the code that was compiled by tcc. So I added a function to return this in tccgen.c but I'm not sure it's ok. It adds another public function and it's the only function that take a TCCState argument in that file.

tcc_relocate(s, NULL) already returns the code+data size.

However I'd suggest not to add another API but instead integrate
this into tcc_relocate.  There is already

        set_pages_executable(ptr, length);

Such if you only want to flush instruction memory, you could just add
        __clear_cache(ptr, lenght);
into this function.  Or just flush the entire allocated memory at the
end of tcc_relocate_ex if you want both data+instructions.

--- grischka

reply via email to

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