📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  Brainstorms - General  >>  ppc64 jump tables/negative offsets? assembly help..

Topic created on: February 13, 2011 09:06 CST by mrwicked .

I wish PPC64 code was as simple as PPC32 code.. :( I'm in the process of reversing a PPC64 executable, but I cannot figure out how the data references are calculated.. I simply cannot wrap my head around the calculation of the %rtoc and the negative offsets..

In basic form there is this (why is the offset negative?):
lwz     %r0, -0x7FF8(%rtoc)

And the recalculation of %rtoc?:

LOAD:0000000000012624                 bl      sub_A35E8
LOAD:0000000000012628                 ld      %rtoc, arg_28(%sp)

# ------------------------------------------
sub_a35e8:
LOAD:00000000000A35E8 .set arg_28,  0x28
LOAD:00000000000A35E8
LOAD:00000000000A35E8                 li      %r12, 0
LOAD:00000000000A35EC                 oris    %r12, %r12, 0xF
LOAD:00000000000A35F0                 lwz     %r12, -0x6F38(%r12)
LOAD:00000000000A35F4                 std     %rtoc, arg_28(%sp)
LOAD:00000000000A35F8                 lwz     %r0, 0(%r12)
LOAD:00000000000A35FC                 lwz     %rtoc, 4(%r12)
LOAD:00000000000A3600                 mtspr   CTR, %r0
LOAD:00000000000A3604                 bctr

And there are functions which include tables; are these so called GOT tables?  and how is this static data referenced?:

LOAD:000000000001B418                 lwz     %r11, -0x6620(%rtoc) # Load Word and Zero
LOAD:000000000001B41C                 rldic   %r9, %r5, 2,30 # Rotate Left Doubleword Immediate then Clear Left MD-form
LOAD:000000000001B420                 lwzx    %r0, %r9, %r11 # Load Word and Zero Indexed X-form
LOAD:000000000001B424                 extsw   %r0, %r0 # Extend Sign Word X-form
LOAD:000000000001B428                 add     %r0, %r0, %r11
LOAD:000000000001B42C                 mtspr   CTR, %r0 # Move To Special Purpose Register XFX-form
LOAD:000000000001B430                 bctr # Branch unconditionally to CTR
LOAD:000000000001B430 # ---------------------------------------------------------------------------
LOAD:000000000001B434                 .long 0x38
LOAD:000000000001B438                 .long 0x50
LOAD:000000000001B43C                 .long 0xC0
LOAD:000000000001B440                 .long 0x110
LOAD:000000000001B444                 .long 0x188
LOAD:000000000001B448                 .long 0x1AC


I've been looking for manuals/explanation, and only found this, but still don't get it..:
http://code.google.com/p/cellos/wiki/UnderstandingPICGOT

Who can help me further?

  mrwicked   February 13, 2011 12:25.17 CST
Ok; the PPC elf64 ABI document is useful for this information..:
http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.pdf

[quote]The initial TOC pointer register value, obtained via the function descriptor pointed at by the e_entry field in the ELF header.[/quote]

It's sort of falling into place now, but if you have something you want to share with me, please..

  acpi     February 15, 2011 08:03.16 CST
Hi, I sent you a message. Maybe this helps.

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit