Recent

Author Topic: How to get functions, procedures infomation from "*.o", "*.ppu"  (Read 4750 times)

vkhoa

  • New Member
  • *
  • Posts: 47
Is there any way to know what procedure or function we can use when including that unit(*.o,*.ppu) in in my program. I googled and find out that there is Cody add-ins for Lazarus can do that,
but is there another way to do that?
I saw in units folder of free pascal there is several compilered units but don't know how to use it.
I also use ppudump but didn't success.
« Last Edit: July 25, 2015, 09:59:24 am by vkhoa »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How to get functions, procedures infomation from "*.o", "*.ppu"
« Reply #1 on: July 25, 2015, 11:18:06 am »
Do you have access to the sources (.pas, .pp) or must you work only from the .ppu?

vkhoa

  • New Member
  • *
  • Posts: 47
Re: How to get functions, procedures infomation from "*.o", "*.ppu"
« Reply #2 on: July 25, 2015, 03:42:55 pm »
Only the *.ppu, *.o,*.a, there is no source file in the folder
Sorry, I used ppudump successfully, I had run "CD" command at the wrong directory, but then, still get no information from it
« Last Edit: July 25, 2015, 04:07:18 pm by vkhoa »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to get functions, procedures infomation from "*.o", "*.ppu"
« Reply #3 on: July 25, 2015, 04:40:23 pm »
ppudump should be able to show, but you must be able to read its output (which is not difficult, but a lot). Unfortunately in many cases it can't parse the .ppu well enough.

`nm --defined-only` on *.o can show all symbols, but you can't tell which section (interface or implementation) they belong to. It will also list symbols which are not typically referred from Pascal level (vmt, initialization/finalization, etc.). Moreover, the symbols are mangled as explained here.

objdump can do the same but has even crazier output as it can disassemble everything, not just showing the symbols. *.a is just an archive of many *.o.

yamer

  • Jr. Member
  • **
  • Posts: 87
Re: How to get functions, procedures infomation from "*.o", "*.ppu"
« Reply #4 on: July 25, 2015, 04:52:42 pm »
Much of FreePascal units are documented :

For undocumented units, sources are available. Just download Freepascal sources : http://sourceforge.net/projects/freepascal/files/Source/2.6.4/ (take fpc-2.6.4.source.zip or fpc-2.6.4.source.tar.gz)
« Last Edit: July 25, 2015, 04:55:01 pm by yamer »

vkhoa

  • New Member
  • *
  • Posts: 47
Re: How to get functions, procedures infomation from "*.o", "*.ppu"
« Reply #5 on: July 26, 2015, 08:48:05 am »
Thanks for all replies!
@yamer, the source files solved my problem, but the ppudump still be useful if there is no document and no source
Then I have tried reading the ppudump's result, compare it to the source file, and knowing some of its syntax, infomation about the procedure's name and parameters's type is from the field Alias name(which is mangled as Leledumbo mentioned) of the procedure definition, but sometimes the parameters type is converted  to a code(which can't be understanded or it reference to something else where).And one more question, how can we understand the field "var type" of "field variable symbol","Parameter Variable symbol" section and the field "prop type" of "property symbol" section, is it a reference ?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12771
  • FPC developer.
Re: How to get functions, procedures infomation from "*.o", "*.ppu"
« Reply #6 on: July 26, 2015, 10:37:47 am »
If the mangled name gets too long, a CRC is appended yes.

Btw the ppudump of FPC 3.x (but only for corresponding ppu versions) has a XML dump feature.

 

TinyPortal © 2005-2018