Re[2]: Proposal: getdirname utility

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Tue, 01 Apr 2025 14:40:49 +0000

>Would a dladdr solution be more elegant and Solaris-friendly?

  It might be Solaris-friendly enough since Solaris does not officially
support static linking. It's probably not a bad heuristic when
everything else fails.

  But elegant? Not by any means. It's a hack that assumes the binary is
dynamically linked (which is only a valid assumption on MacOS and
Solaris and only because of an arbitrary limitation enforced by the
vendors), and that it has a "main" symbol - which is probably true since
it's C, but _start would be a more reliable entry point, and even then
it's still a convention, and...

  Yeah. Not going into the weeds of parsing ELF headers. It's probably
good enough, and giving up if dladdr(main) fails sounds reasonable.
Still, this is the kind of heuristic that has a lot of possible,
obscure failure modes and that I'm in no hurry to add to skalibs,
especially if its only application is to fight unnecessarily restrictive
service launchers.

--
  Laurent
Received on Tue Apr 01 2025 - 16:40:49 CEST

This archive was generated by hypermail 2.4.0 : Tue Apr 01 2025 - 16:41:18 CEST