public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Keep certain relocation entries
@ 2008-09-04  8:58 Bernhard Poess
  2008-09-04 17:13 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Poess @ 2008-09-04  8:58 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Keep certain relocation entries
  2008-09-04  8:58 Keep certain relocation entries Bernhard Poess
@ 2008-09-04 17:13 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2008-09-04 17:13 UTC (permalink / raw)
  To: Bernhard Poess; +Cc: gcc-help

"Bernhard Poess" <sigmaz3r0@gmail.com> writes:

> 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.

This is really a function of the assembler, not the compiler.

When using ELF, the assembler should always generate a relocation if
the function is not static.  If the function is static, I don't think
there is any way to force the relocation.  You would have to add an
option to the assembler.  If you are using gas, you would want to
change adjust_reloc_syms in gas/write.c.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-09-04 17:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-04  8:58 Keep certain relocation entries Bernhard Poess
2008-09-04 17:13 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).