Hacker News new | ask | show | jobs
by mpyne 4501 days ago
AFAIK static linking doesn't bring in "used functions".

It brings in used libraries, all at once. E.g. if you used sincos() from math.a, and math.a contained 47 other math functions, then you'd get all 48 math functions in your static binary just from using sincos().

Someone correct me if I'm wrong but I believe it's only with good whole program optimization at link time that it's possible to truly prove that a function is unneeded and exclude it (and then re-link if needed to re-resolve symbols to their new address in virtual memory).

1 comments

You are wrong... sort of. It brings in used objects. A library can be made up of many objects; unused ones will be discarded.
Ah, good point, thanks for the correction.