[英]Prevent debug information for array of enumerated type from appearing in EXE
I open up the Delphi IDE and create a new project.我打开 Delphi IDE 并创建一个新项目。 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
".我构建了应用程序,然后在 EXE 中搜索“
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
.我再次搜索 EXE,现在没有提到
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
.我得到一个未使用变量的提示,但 EXE 仍然没有提到
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.我搜索了 EXE,发现“
tMyEnum
”现在出现在 EXE 文件中。
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我正在使用 Delphi 10.2
In response to David Heffernan, I've added these compiler directives.为了回应 David Heffernan,我添加了这些编译器指令。
program EnumSymbolsInExeTest1;
{$WEAKLINKRTTI ON}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
type
tMyEnum = ( A );
var
Z : array of tMyEnum;
begin
end.
My EXE still contains "tMyEnum".我的 EXE 仍然包含“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.现在标识符不再出现在 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.并且该符号仍然出现在最终 PE 模块的
.text
部分中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.