Git Product home page Git Product logo

tinycc's Introduction

ARM Thumb output

To use this:

  • Configure it with cross-compilation enabled, then use any ARM target
  • I've been using ./arm-linux-gnueabi-tcc -nostdinc -nostdlib -c test.c -o test.o to compile, and arm-none-eabi-objdump -S test.o to dump the output
  • I was comparing it with what I got from arm-none-eabi-gcc -mlittle-endian -mthumb -mcpu=cortex-m3 -mfix-cortex-m3-ldrd -mfloat-abi=soft -nostdinc -nostdlib -c test.c -o test.o

In terms of implementation:

  • Everything is in arm-gen.c.
  • tcc-gen.c has a single mod, which adds one to the symbol address (signifying that the symbol is Thumb, not ARM). There must be a nicer way of doing this, but hey - proof of concept.
  • I added ot() which outputs a thumb instruction - the original o() would output a 32 bit ARM instruction - so every call to o() needs replacing with a thumb equivalent
  • The function prolog/epilog is hacked up at the moment so only works with very basic stuff (no stack pushing)
  • encbranch/decbranch/gsym_addr do seem to work, but encbranch won't work reliably for conditional branches as these have less bits for the address

Would be nice:

  • Ideally we'd start out with a new thumb-gen.c containing stubs - it would get rid of the RELICENSING issue
  • Find a way to separate ARM and Thumb code gen (ideally separate files), and maybe make TCC respect the -mthumb switch like GCC does (rather than having a separate binary).

test.sh

#!/bin/bash
arm-none-eabi-gcc -mlittle-endian -mthumb -mcpu=cortex-m3  -mfix-cortex-m3-ldrd -mfloat-abi=soft -nostdinc -nostdlib -c test.c -o test.o 
echo ------------------------------------------------
echo   GCC
echo ------------------------------------------------
arm-none-eabi-objdump -S test.o
mv test.o test-gcc.o


./arm-linux-gnueabi-tcc -nostdinc -nostdlib -c test.c -o test.o 
echo ------------------------------------------------
echo   TCC
echo ------------------------------------------------
arm-none-eabi-objdump -S test.o
mv test.o test-tcc.o

test.c

// test.c
int foobar() {
  return 4;
}

Original README

is here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.