Re:The .a File Is a Relic: Why Static Archives Were a Bad Id...
by accelbred on Tuesday July 22, 2025 @11:50AM
(#44648703)
so files require PIC code, which brings along symbol interpolation.
[ Parent
| on HN ]
Re:The .a File Is a Relic: Why Static Archives Were a Bad Id...
by EE84M3i on Tuesday July 22, 2025 @09:09PM
(#44654748)
Shouldn't you use PIE for executables anyway?
Re:The .a File Is a Relic: Why Static Archives Were a Bad Id...
by accelbred on Tuesday July 22, 2025 @09:18PM
(#44654818)
PIE code is different than PIC. PIE can assume no interposition.
Re:The .a File Is a Relic: Why Static Archives Were a Bad Id...
by EE84M3i on Tuesday July 22, 2025 @11:38PM
(#44655511)
Sorry what do you mean by "symbol interpolation" and "interposition" in this context?
Natively I would assume you can just take the sections out of the shared object and slap them into the executable. They're both position independent so what's the issue?
If PIE allows greater assumptions to be made by the compiler/linker than PIC that sounds great for performance, but doesn't imply PIC code won't work in a PIE context.
Re:The .a File Is a Relic: Why Static Archives Were a Bad Id...
by accelbred on Wednesday July 23, 2025 @01:14AM
(#44655911)
PIC code would work where PIE does, but likely perform worse. In shared libraries, calls to any non-static function can't be assumed to be the same function at runtime, since another library linked or using LD_PRELOAD may also define the symbol. Thus all calls to non-static functions must go through the shared library lookup machinery. This prevents inlining opportunites as well. Functions in an executable can't be overwridden in this manner, and override the symbols in shared libraries. Thus PIE code can have cheaper function calls and freely inline functions.
Its not that you couldn't use the PIC code, but it would be better to just recompile with PIE.