[Top][All Lists]

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

[Tinycc-devel] Tinycc for ARM help needed !

From: Domingo Alvarez Duarte
Subject: [Tinycc-devel] Tinycc for ARM help needed !
Date: Wed, 2 Apr 2014 22:42:28 +0100

Hello all !

I'm still fighting to make tinycc on ARM work properly, to test it I'm using fossil-scm as a test program because it's not a trivial program and self contained, tinycc on linux 32 and 64 bits already is capable of generate working programs form it but on ARM right now it compiles but the program do not produce the correct results.

One technique I was willing to use is to generate a callgraph of the program on linux (that is done) and then on ARM (here is the trouble).

For that I'm using a translated program from bash/awk (http://publicclu2.blogspot.co.uk/2013/05/call-graph-generation.html) to lua with some fixes (see attached), the other possibility would be to use "valgrind --tool=callgrind" but the tinycc generated programs are rejected from valgrind for several reasons:

1- "Inconsistency detected by ld.so: rtld.c: 1292: dl_main: Assertion `_rtld_local._dl_rtld_map.l_libname' failed!" for this one I found a workaround making a change on tccelf.c (it's on the mob but commented because it has a side effect of programs generated with debug information and stripped afterwards segfaults).

2- "disInstr(arm): unhandled instruction: 0xE3511000  cond=14(0xE) 27:20=53(0x35) 4:4=0 3:0=0(0x0)" on ARM the programs generated with tinycc emits a combination of instructions that confuses valgrind (note the same program compiled with gcc works fine with valgrind).

3- "Invalid read of size 4 ... Address 0x????? is just below the stack ptr."  on ARM the programs generated with tinycc manage the stack in a way that confuses valgrind/gdb (note the same program compiled with gcc works fine with valgrind).

With GDB and the lua script attached it also fails because the way tinycc generated programs manipulate the stack:
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "armv7l-unknown-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from check-va-tcc...done.
(gdb) b main
Breakpoint 1 at 0x8260: file check-va.c, line 18.
(gdb) r
Starting program: /home/mingo/dev/tmp/check-va-tcc 

Breakpoint 1, main () at check-va.c:18
18  myprintf ();
(gdb) s
myprintf () at check-va.c:13
13    return passdown();
(gdb) bt 2
#0  myprintf () at check-va.c:13
#1  0xbefff628 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) s
Cannot access memory at address 0x0
passdown () at check-va.c:8
8  return db_prepare();
(gdb) bt 2
#0  passdown () at check-va.c:8
#1  0xbefff618 in ?? ()
Cannot access memory at address 0x0
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) s
db_prepare () at check-va.c:3
3  return 2;
(gdb) bt 2
#0  db_prepare () at check-va.c:3
#1  0x0000822c in passdown () at check-va.c:8
Cannot access memory at address 0x0
(More stack frames follow...)

So my call for help from anyone with tinycc/ARM knowledge is how we can make tinycc generated programs on ARM to play nice with valgrind/gdb ? Mainly the stack issue (attached we have a obdump of the same sample with gcc and tcc).

If we can achieve this investigate why tinycc generated programs like fossil-scm to not work properly will be a bit easier.

Thanks in advance for your time, attention and any help ! 

Attachment: check-va-gcc-calls.txt
Description: Text document

Attachment: callgraph
Description: Binary data

Attachment: callgraph.lua
Description: Text Data

Attachment: check-va.c
Description: Text Data

Attachment: check-va-mk
Description: Binary data

Attachment: check-va-gcc.o.dump.asm
Description: Binary data

Attachment: check-va-tcc.o.dump.asm
Description: Binary data

Attachment: check-va-tcc-calls.txt
Description: Text document

reply via email to

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