Keep certain relocation entries

Bernhard Poess sigmaz3r0@gmail.com
Thu Sep 4 08:58:00 GMT 2008


Hi,

For a research project I'm searching for a way to tell gcc to add a
relocation entry for relocations like this:

leaq function(%rip), %some_reg

where function is a resolved symbol in the same assembler file and the
value of function is known.

Is there some switch? Do I have to change the source? If so, where?
I'm working on x86_64 (as you might have guessed).

Big Picture:
I'm searching for a way to automatically find function pointers that
Linux modules hand over to the Linux kernel.

E.g.

struct device dev = {
 .probe = my_probe,
 .transmit = my_transmit,
}

those get relocation entries of type R_X86_64_64. However if somewhere
in the code somebody does

dev.probe = &my_probe

then this translates to

leaq my_probe(%rip), %rax

and a R_X86_64_PC32 relocation if and only if my_probe's value is not
know to the assembler.

so far I've been hunting down R_X86_64_64 and R_X86_64_PC32
relocations of the above kind. But for some calls there is no
relocation entry (see above). If this could be solved at a better
stage than the relocator, let me know.


Thanks,
-Bernhard



More information about the Gcc-help mailing list