Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent debug information for array of enumerated type from appearing in EXE

Tags:

delphi

I open up the Delphi IDE and create a new project. Here's the whole code for the application:

program EnumSymbolsInExeTest1;

type
  tMyEnum = ( A );

begin
end.

I build the application, and then search the EXE for "tMyEnum". It is found. That's no surprise because I have Debug Information set ON in the Linker options.

I turn off Debug Information. I rebuild. I search the EXE again and now there is no mention of tMyEnum. So far everything is as expected.

Then I change the code. I add a variable.

program EnumSymbolsInExeTest1;

type
  tMyEnum = ( A );

var
  Z : tMyEnum;

begin
end.

I rebuild. Still no surprises. I get a hint for an un-used variable, and the EXE still has no mention of TMyEnum.

Then I make another small change:

type
  tMyEnum = ( A );

var
  Z : array of tMyEnum;

begin
end.

I change the variable to an array. I rebuild. I search the EXE and find that "tMyEnum" now appears in the EXE file.

My questions are: Why?

And how can I stop it? I don't want any of my internal identifiers to appear in the executable file I send to my customers.

I am using Delphi 10.2

In response to David Heffernan, I've added these compiler directives.

program EnumSymbolsInExeTest1;

{$WEAKLINKRTTI ON}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}

type
  tMyEnum = ( A );

var
  Z : array of tMyEnum;

begin
end.

My EXE still contains "tMyEnum".

I have a new clue! I changed the array from dynamic to static.

program EnumSymbolsInExeTest1;

type
  tMyEnum = ( A );

var
  Z : array [1..10] of tMyEnum;

begin
end.

Now the identifier no longer appears in the EXE.

So the declaration of the type does not trigger it, adding a variable of that type does not trigger it, adding a static array does not trigger it, but making it a dynamic array does.

like image 632
David Dubois Avatar asked Nov 24 '19 13:11

David Dubois


1 Answers

I'm going to say it's not possible.


Conclusion from direct experimental observation

Try turning off every option that we can find:

Compiling

  • Code inlining control: Off
  • Emit runtime type information: false
  • Optimization: true
  • Assertions: false
  • Debug information: No debug information
  • Local symbols: false
  • Symbol reference info: None
  • Use debug .dcus: false
  • Use imported data references: false
  • I/O Checking: false
  • Overflow checking: false
  • Range checking: false
  • Assignable typed constants: false
  • Complete boolean evaluation: false
  • Extended syntax: false
  • Long strings by default: false
  • Open parameters: false
  • Strict var-strings: false
  • Typed @ operator: false

Linking

  • Debug information: false
  • Include remote debug symbols: false
  • Map file: Off
  • Output resource string .drc file: false

And the symbol still appears in the .text section of the final PE module.

enter image description here

like image 122
Ian Boyd Avatar answered Sep 26 '22 00:09

Ian Boyd