jeudi 5 juin 2014

How to redefine symbols belonging to a certain function of the .text section of an object file


Vote count:

0




My object file contents are as follows:



john:~/temp1/compile3$ objdump -r -d main.o
main.o: file format elf64-x86-64
Disassembly of section .text:

0000000000000000 <printer2>:
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: bf 00 00 00 00 mov $0x0,%edi
5: R_X86_64_32 .rodata
9: e8 00 00 00 00 callq e <printer2+0xe>
a: R_X86_64_PC32 puts+0xfffffffffffffffc
e: c9 leaveq
f: c3 retq

0000000000000010 <main>:
10: 55 push %rbp
11: 48 89 e5 mov %rsp,%rbp
14: b8 00 00 00 00 mov $0x0,%eax
19: e8 00 00 00 00 callq 1e <main+0xe>
1a: R_X86_64_PC32 printer2+0xfffffffffffffffc
1e: c9 leaveq
1f: c3 retq


I want to replace the printer2 symbol with printer1 only in the main function and not in the printer2 function.


I tried using objcopy main.o --redefine-sym printer1=printer2, but that replaced symbols in all the functions.


Kindly help me in this regard.



asked 38 secs ago






Aucun commentaire:

Enregistrer un commentaire