<html><head></head><body><div>Hi Michalis,</div><div><span><pre><br></pre></span></div><div>On Thu, 2025-02-06 at 22:04 +0100, Michalis Kamburelis wrote:</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>As you may noticed, I was recently very busy with making FPC provide an easy way to build hardened programs.<br></div><div><br></div><div>I think I'm now done with that and 3.2.2-45 should be, I hope, the last upload with regards to that goal. It fixed the aarch64 architecture, the only remaining architecture for which FPC supports PIC/PIE.<br></div><div><br></div><div>The current situation makes developers live easy, just add @hardening to your fpc compilation command line and it will do it.<br></div></blockquote><div><br></div><div>I'm interested -- can you provide some details, what does exactly the<br></div><div>"hardening" imply, what happens as a result?</div></blockquote><div>By hardening Debian means enabling Position Independent Code (PIC) and Position Independent Executable (PIE). These are mainly code generator option (-Cg) and linker option (-pie).</div><div><br></div><div>On the context of FPC it is adding a configuration file in <a href="https://salsa.debian.org/pascal-team/fpc/-/blob/master/debian/hardening.cfg?ref_type=heads">/etc/fpc-3.2.2.cfg.d/hardening</a> that allows calling <i><b>fpc @hardening myprog</b></i> to enable these options in a standard way.</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div> E.g. does this mean<br></div><div>enabling things like range checking, overflow checking using FPC<br></div><div>options, to catch buffer overflows etc. in certain cases, or something<br></div><div>else? I read <a href="https://wiki.debian.org/Hardening">https://wiki.debian.org/Hardening</a> ,</div></blockquote><div>No it does not enable such features, but indeed these can be a big plus when testing. However, I fear a program that crashes due to input will not be welcome even if I prefer that behavior to silently continue with a buffer overflow that can be used by a hacker.</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div> from what I<br></div><div>understand the precise meaning of "hardening" depends on the compiler<br></div><div>and toolchain, so in Debian+Pascal context the "hardening" implies<br></div><div>passing certain command-line options to the FPC compiler. What are<br></div><div>these options exactly, so that I can confirm that e.g. Castle Game<br></div><div>Engine really supports it 100%?<br></div></blockquote><div>The entire set of options is described in the link above, but mainly -XD, -Cg, -k-lc, -k--dynamic-linker=<some so file></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><br></div><div>Sorry in advance if this is already documented somewhere, in wiki or<br></div><div>source code, just point me to it :)<br></div></blockquote><div>There are many bu none is complete, so good that you asked, at least this mail can be used as a start of a doc page.</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><br></div><div>Note that CGE does support debug and release modes of compilation, and<br></div><div>we fully support compiling the CGE codebase with range checking,<br></div><div>overflow etc. enabled.</div></blockquote><div>One day, we may try to take advantage of such FPC feature to ensure code is 100% safe. However today this is not the case.</div><div>Also, one argument to disable such a feature that was the default in TP7, was the speed reduction due to checks overhead. However this is tiny compared to Python or Java overload. So maybe FPC is a good candidate to become the next safe coding language!</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div> But this is not 100% true for all Pascal code,<br></div><div>I recall some FPC RTL code that was doing tricks and just assuming<br></div><div>that range checking is off, otherwise an "innocent" (actually valid)<br></div><div>code will raise range errors.<br></div></blockquote><div>That code is generally not portable over architectures.</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div>Now, there was a price for that, and one additional unitary test is now failing on i386. It deals with generics, which I don't think too much people use, but I hope it will get fixed soon by 3.2.4 that I expect to be in the few coming weeks.<br></div></blockquote><div><br></div><div>Note that Castle Game Engine uses generics very intensively. And I do<br></div><div>recommend everyone to use generics in my "Modern Object Pascal<br></div><div>Introduction for Programmers", providing examples e.g. here<br></div><div><a href="https://castle-engine.io/modern_pascal#generic-containers-section">https://castle-engine.io/modern_pascal#generic-containers-section</a> .<br></div></blockquote><div>Then you may be interested in checking <a href="https://salsa.debian.org/pascal-team/fpc/-/commit/c5ea8c3d5ff4f3ad2efcdaaae8e9b8bc04bfe326">this commit</a>.</div><div><br></div><div>I disabled the test because I know FPC core team will never want to deal with a 3.2.2 bug as they are trying to get 3.2.4 out, even if this is the case since last year same time.</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div><br></div><div>Regards and thank you for all the work,<br></div><div>Michalis</div></blockquote><div>Thank you also for your fantastic work on CGE and CMV.</div><pre style="caret-color: rgb(46, 52, 54); color: rgb(46, 52, 54); font-variant-caps: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4); -webkit-text-stroke-width: 0px; text-decoration: none;">-- <br></pre><pre style="caret-color: rgb(46, 52, 54); color: rgb(46, 52, 54); font-variant-caps: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0.4); -webkit-text-stroke-width: 0px; text-decoration: none;">Cheers,
Abou Al Montacir</pre><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"></blockquote></body></html>