This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

partial linking that resolves relocations


Hi,

I'm not sure I'm using the correct terminology, so I will use a simple example:

Assuming two C files:

$ cat 1.c
void foo();

void lala() {
? ? ? ?foo();
}
$ cat 2.c
void foo(){}

$ gcc -c 1.c
$ gcc -c 2.c

$ objdump -dr 1.o
0000000000000000 <lala>:
? 0: ? 55 ? ? ? ? ? ? ? ? ? ? ?push ? %rbp
? 1: ? 48 89 e5 ? ? ? ? ? ? mov ? ?%rsp,%rbp
? 4: ? b8 00 00 00 00 ? mov ? ?$0x0,%eax
? 9: ? e8 00 00 00 00 ? callq ?e <lala+0xe>
? ? ? ? ? ? ? ? ? ? ? ?a: R_X86_64_PC32 ? ? ? ?foo+0xfffffffffffffffc
? e: ? 5d ? ? ? ? ? ? ? ? ? ? ? pop ? ?%rbp
? f: ? c3 ? ? ? ? ? ? ? ? ? ? ? ? retq

Is there a way to combine object files (1.o and 2.o) to produce another
object file (similar to ld -i) with the relocations "resolved"?

In this particular case I would want something like:

00000000004004a4 <foo>:
?....
0000000000400494 <lala>:
?400494: ? ? ? 55 ? ? ? ? ? ? ? ? ? ? ?push ? %rbp
?400495: ? ? ? 48 89 e5 ? ? ? ? ? ? mov ? ?%rsp,%rbp
?400498: ? ? ? b8 00 00 00 00 ? mov ? ?$0x0,%eax
?40049d: ? ? ? e8 02 00 00 00 ? callq ?4004a4 <foo>
?4004a2: ? ? ? 5d ? ? ? ? ? ? ? ? ? ? ? pop ? ?%rbp
?4004a3: ? ? ? c3 ? ? ? ? ? ? ? ? ? ? ? retq


I want to use this as a quick fix for two libraries that export the same symbol.

Thanks,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]