Solved

Delphi3 compiler options

Posted on 2001-06-21
10
414 Views
Last Modified: 2010-04-06
I looked at part of my compiled application and found that it was not fully compiled.
Instead of an .exe consisting of only machine code there are bits of text of object parameters, procedure names, etc.
My guess is that instead of generating machine code for some objects it is just imbedding them as they are and jumping to them when required. It looks more like interpreted code instead of compiled code.
I've looked at 'all' the compiler options but I can't find anything that would produce this effect.
I suppose there's a 'fast compile' option that does this and then a 'full compile' option to produce the final code.
Can you please tell me which option(s) I need to set to produce fully compiled machine code.


0
Comment
Question by:frog
  • 3
  • 2
  • 2
  • +3
10 Comments
 

Accepted Solution

by:
Micke_Holm earned 50 total points
ID: 6213503
Hi frog,

There is no such switch as Delphi compiles to natvive machine code.

What you saw was the resources for forms and data modules. Delphi puts them in a special format as a ordinary Win32 resource. It uses that information to create the forms and data modules in run time.

//Micke
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 6213516
Huh? Delphi doesn't produce interpreted code. If you look at any Delphi EXE you'll find chunks of text that appear familiar but the file is fully compiled (don't worry). Just in case, here are the settings that I use (and as I haven't changed them they're the Delphi defaults):

Compiler (the following are on, the rest are off):
Optimisation
Aligned Record Fields
I/O errors
Debug Info
Local Symbols
Reference info
Definitions Only
Assertions
Show Hints
Show Warnings
Strict var-strings
Extended Syntax
Open parameters
Huge strings
Assignable typed constants

Linker:
Map file - OFF
Linker Output - Generate DCU's

Hope that's what you needed

The Neil =:)
0
 
LVL 17

Expert Comment

by:inthe
ID: 6214050
hi,
im wondering what you were expecting it to be ?
if you look at any exe with a hex editor you'll see strings ..dont worry it is very normal.
when you compile it doesnt turn abc into 110011 or xzy it just compiles to machine readable code.this is why you would never hardcode passwords/serial numbers etc into applications and pretty much why encryption is used as with encryption you can turn abc into zxy.

Regards Barry
0
 

Author Comment

by:frog
ID: 6214378
Thanks for your comments.

Inthe, I was expecting to see the text for messageDlgs etc as text, but that was all.
I expected the rest to contain a contiguous stream of hex code that the processor would process. ( Stuff like 7E FE 61 DA  that would cause the processor to load accumulator A from HL compare it with character 'a' etc, etc.)
I didn't expect to see anything that would give any visual clues as to what the code was doing. And I certainly did not expect to see text reference to say a button, but just the hex code to create the button, ie a heap of instructions to load accumulators, shift, compare etc, etc to finally draw the button.

I reckon Micke has answered my question by saying that Delphi uses resources embedded inside the 'compiled'  .exe  "to create the forms and data modules in run time."
Just why it would create them at run time and not at compile time only adds more questions. It must be awfully slow to create objects on the fly at run time, but I suppose it gives some flexibility.
This reminds me of a question that's been on my mind for a while - why don't the Delphi handbooks and help screens give the number of machine cycles for each instruction. I've only seen references like "inc(a) is faster than a := a+1"  but there's no reference to how much faster, like "inc(a) = 4 machine cycles, a := a+1 = 27 cycles".

It sounds like it's all to do with Windows,  is it that my exe isn't actually run directly by the processor, but that it tells Windows to draw a form and Windows then gets the processor to run code within Windows to draw it?
0
 

Author Comment

by:frog
ID: 6214399
Thanks for your comments.

Inthe, I was expecting to see the text for messageDlgs etc as text, but that was all.
I expected the rest to contain a contiguous stream of hex code that the processor would process. ( Stuff like 7E FE 61 DA  that would cause the processor to load accumulator A from HL compare it with character 'a' etc, etc.)
I didn't expect to see anything that would give any visual clues as to what the code was doing. And I certainly did not expect to see text reference to say a button, but just the hex code to create the button, ie a heap of instructions to load accumulators, shift, compare etc, etc to finally draw the button.

I reckon Micke has answered my question by saying that Delphi uses resources embedded inside the 'compiled'  .exe  "to create the forms and data modules in run time."
Just why it would create them at run time and not at compile time only adds more questions. It must be awfully slow to create objects on the fly at run time, but I suppose it gives some flexibility.
This reminds me of a question that's been on my mind for a while - why don't the Delphi handbooks and help screens give the number of machine cycles for each instruction. I've only seen references like "inc(a) is faster than a := a+1"  but there's no reference to how much faster, like "inc(a) = 4 machine cycles, a := a+1 = 27 cycles".

It sounds like it's all to do with Windows,  is it that my exe isn't actually run directly by the processor, but that it tells Windows to draw a form and Windows then gets the processor to run code within Windows to draw it?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Expert Comment

by:Gwena
ID: 6217179
If you want your exe files to be inscrutable then get yourself one of the many free exe encryptors... they usually install a small asm program near the start of your exe and when your exe runs this decrypts the bytes of the exe before they are placed into memory.... you could compress the exe first and then encrypt it... that ought to make it look strange and plain-text free to snoopers with a hex editor :-)
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6217440
> It must be awfully slow to create objects on the fly at run time

I don't think so but it can be tested very easily, by creating a form with some components at designtime and then another at runtime in code, and comparing the times they take to create.

If you're worried about using the .dfm resources, don't use them.

GExperts www.gexperts.org even have a wizard called 'Components to Code' which will allow you to design a form and then generate the corresponding code for selected components.

> why don't the Delphi handbooks and
help screens give the number of machine cycles for each instruction

Try View\Debug Windows\CPU menu during debugging ;-)
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6217444
Oops, for Delphi 3 you need to add a registry entry to enable the CPU View:

http://delphi.about.com/compute/delphi/library/howto/htcpuview.htm
0
 

Author Comment

by:frog
ID: 6217671
Thanks to everyone.
You have all been helpful, so I'll accept the first comment as the answer and then post points for the rest.

0
 
LVL 17

Expert Comment

by:inthe
ID: 6220517
just to note
>>is it that my exe isn't actually run directly by the processor

exactly otherwise we could run our applications irrespective of operating stsyem..delphi is compileing our app to a win32 pe format exe which is i suppose you could say controlled by the windows os..
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now