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.
I'm going to say it's not possible.
Conclusion from direct experimental observation
Try turning off every option that we can find:
Compiling
Linking
And the symbol still appears in the .text section of the final PE module.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With