Chain Tools
October 8, 2010 – 12:38 pm | No Comment

Welcome to ChainTools.com where you’ll find all of the Chain Tools you can’t find anywhere else. No matter what your needs are you will be able to find the right products, accessories, colors and brands …

Read the full story »
Decorating & Remodeling

Do It Yourself (DIY)

Engineering

Hobbies & Crafts

Motorcycles

Home » Programming & Design

MIPS – compiling relocatable code with SDE-GCC ?

Submitted by on March 13, 2010 – 5:49 pmOne Comment
chain tools
Nice Z asked:

Hi,
I’m using SDE-GCC to compile programs that runs on “bare iron” (i.e. no operating system). I would like to be able to create programs (“executables”) that can be loaded to arbitrary addresses on RAM and run from there.

I used to compile and run successfully such kind of programs on ARM processor (with different tool-chain of course) where the program was PC relative. MIPS don’t expose the PC and seems it has its own way to
do it.

I tried to use -mabicalls -fPIC compilation flags to create PIC (Position Independent Code): when I examined the “objdump” I could find that the “GOT” (global offset table) is still made of absolute
addresses so the program is bounded to run on a specific address (the linking address).

Can you direct me on how to do that?

Thanks in advance,

Eli

One Comment »

  • Tizio 008 says:

    «that can be loaded to arbitrary addresses on RAM and run from there.»
    if the MIPS arch does not allow it, you must write a loader that relocate the code whereever you want :)

    as far as i can see, MIPS allow “relative” coding, so… just be sure you dont use j, jal, and more… for the rest, e.g.
    lb and more, i can see they accept a offset, so the way the new PC (or Instr Pointer as you prefer) is calculated allow for relative address independent code (if the code is all inside the max range offsets can span!)

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar .