Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2026-10

Symbols in binary

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Adriaan van Os

Consider the following test program:

program symbols;
var
stat: TFPCHeapStatus;
begin
stat := GetFPCHeapStatus;
   writeln( 'FPC FPCHeapStatus.CurrHeapUsed = ', stat.CurrHeapFree)
end.

When I compile it with -XX- -Xs, there is a string "TFPCHeapStatus" in a Mach-O (__TEXT, __const) section. When I compile it with -XX, the string "TFPCHeapStatus" in not in that same Mach-O (__TEXT, __const) section, nor anywhere else. Is that expected behaviour ? And how do I get rid of unnecessary symbols like "TFPCHeapStatus" when not smart-linking ?

Regards,

Adriaan van Os

Sven Barth
to Adriaan van Os
Adriaan van Os wrote 16 lines
Consider the following test program: program symbols; var stat: TFPCHeapStatus; begin stat := GetFPCHeapStatus;   writeln( 'FPC FPCHeapStatus.CurrHeapUsed = ', stat.CurrHeapFree) end. When I compile it with -XX- -Xs, there is a string "TFPCHeapStatus" in a Mach-O (__TEXT, __const) section. When I compile it with -XX, the string "TFPCHeapStatus" in not in that same Mach-O (__TEXT, __const) section, nor anywhere else. Is that expected behaviour ? And how do I get rid of unnecessary symbols like "TFPCHeapStatus" when not smart-linking ?

The string "TFPCHeapStatus" is from the RTTI for the record. Considering that you're not using it (e.g. by using "TypeInfo(TFPCHeapStatus)"), smart linking will detect that and not link it in, that's the purpose of smart linking after all. Without smart linking all such identifiers will be linked in. This is by design.

Regards,
Sven