[fpc-devel] Smart-linking on linux/x86-64

Joost van der Sluis joost at cnoc.nl
Thu Jul 7 23:05:06 CEST 2022

Op 05-07-2022 om 11:51 schreef Sergei Gorelkin via fpc-devel:
> 05/07/2022 09:39, Sven Barth via fpc-devel wrote:
>> Joost van der Sluis via fpc-devel <fpc-devel at lists.freepascal.org 
>> <mailto:fpc-devel at lists.freepascal.org>> schrieb am Di., 5. Juli 2022, 
>> 00:17:
>> The problem is that *something* would need to reference the debug 
>> sections otherwise they are stripped as well. But as soon as they're 
>> referenced whatever code or data *they* reference is kept as well.
>> One of the better solutions might be to write these references as weak 
>> symbols (on systems that support this) so at least the data/function 
>> isn't kept around.
>> Or the section of the data/function would have to contain a reference 
>> to its corresponding debug entry so that it is kept around as long as 
>> the function/data is kept around...
>> How does GCC do this?
> As far as I had studied this issue, ld essentially "decompiles" the 
> monolithic FDE's from object files into internal representation, and 
> then "compiles" it back, omitting information for the code that won't go 
> into executable due to smartlinking. It also optimizes for size by using 
> 8- and 16-bit offsets instead of 32-bit ones when possible.

Indeed, that is also what I have seen. ld Adapts the cfi-contents. (It 
also removed some mistakes in fpc's implementation)



More information about the fpc-devel mailing list