relocation questions

guilherme antoniolo antoniolo@gmail.com
Thu Sep 24 13:32:00 GMT 2009


I'm basically compiling modules(object files) with several weak
function definitions(need to be relocated). I have a running program
that brings and consumes those modules in memory, similarly to dlfnc.

While inspecting the generated code in the modules with objdump tool,
I found out that compiler doesn't generate far calls for functions
that need to be relocated. In order to do so, I would have to increase
a byte for every unrelocated function. As you can imagine, this patch
strategy will potentially break every single PC based code.

Curiously, when inspecting the whole build process, I found out that
linker patches the near call to a near jump instruction, then through
a table (I suppose) it performs another jump, a far one. In other
words, two jumps.

1) why performing two jumps over a far call?


I also read in docs that there is an implementation -mlong-calls
available for ARM. If I understood it correctly, that would be exactly
what I'm looking for.

2) Is there a way to induce gcc for doing something similar to me? I
tried unsuccessfully to do it through inline asm.


I'm about to implement the two jumps procedure, but I would love to
know if there is another elegant way.


Much appreciated



More information about the Gcc-help mailing list