Lazarus

Free Pascal => General => Topic started by: Borneq on December 12, 2019, 08:59:18 am

Title: FPC intenals
Post by: Borneq on December 12, 2019, 08:59:18 am
Where can I find detailed info about ppu and obj formats, are tools for dump/disassembling it? FPC compiler can generate assembler sources? can optimize methods to inline?
Title: Re: FPC intenals
Post by: af0815 on December 12, 2019, 09:06:22 am
About info about the ppu format i have got the answer, there is no documentation (see https://forum.lazarus.freepascal.org/index.php/topic,47582.msg342026.html#msg342026 )
Title: Re: FPC intenals
Post by: PascalDragon on December 12, 2019, 09:12:21 am
Where can I find detailed info about ppu and obj formats,

There is no documentation for ppu files. You'll need to look at the source to understand them.

The object files that are generated have the same format as normal object files for the platform. These are among others COFF (https://en.wikipedia.org/wiki/COFF) on Windows and ELF (https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) on Linux.

are tools for dump/disassembling it?

To dump ppu files you can use the ppudump utility that is provided with each FPC distribution. Please note that the used version must match the version of the ppu (meaning that you can't use a FPC 2.6.4 ppudump for a 3.3.1 ppu).

For the object files you can use the GNU utility objdump which allows you to display various information about the object file and also to disassemble them.

FPC compiler can generate assembler sources?

You can see the assembler sources if you pass -al when compiling. If you want to stop FPC from assembling and linking its files then you can use -sh which will keep the assembly files around and also generate a ppas.sh/ppas.bat which allows you to manually assemble/link the files.

can optimize methods to inline?

Yes, FPC can inline routine. Either you can manually declare a method as inline (https://www.freepascal.org/docs-html/ref/refsu73.html) or enable auto inlining using -Ooautoinline. In both cases the method body needs to have been parsed before it is called otherwise the routine won't be inlined.

For example:

Code: Pascal  [Select][+][-]
  1. unit foo;
  2.  
  3. interface
  4.  
  5. procedure Test; inline;
  6. procedure TestA;
  7. procedure TestB;
  8.  
  9. implementation
  10.  
  11. procedure TestA;
  12. begin
  13.   Test; // this will not be inlined
  14. end;
  15.  
  16. procedure Test;
  17. begin
  18. end;
  19.  
  20. procedure TestB;
  21. begin
  22.   Test; // this will be inlined
  23. end;
  24.  
TinyPortal © 2005-2018