logoalt Hacker News

gpmtoday at 5:11 AM1 replyview on HN

> Well, Rust sort of does, if you're OK with using C ABI (i.e. `unsafe`).

Rust has full blown safe dynamic linking - so long as you use rust, and the the same compiler version, for everything. What it doesn't have is runtime libdl support for that. Which would be a problem for the current pam architecture.

I'm not particularly convinced you couldn't just re-architect pam to use static linking though. Or a scripting language.


Replies

pizlonatortoday at 5:50 AM

> Rust has full blown safe dynamic linking - so long as you use rust, and the the same compiler version, for everything.

This is UB in rust as far as I understand:

1) you compile bar using version 1.5 of libfoo.so at link/compile time

2) you update libfoo.so to version 1.6. It has a lot of changes, but is still source compatible and some kind of reasonable precautions were taken, like that struct layouts are the same

3) you run bar with the new libfoo.so version 1.6

This is UB even if you use the same compiler.

If this is UB then that’s not “full blown safe dynamic linking”.

Note that Fil-C does safely support this. This is safe in Fil-C even if you don’t take appropriate precautions (like if you change function signatures, change struct layouts, etc - it’ll still be safe and have well defined outcomes in Fil-C).

show 1 reply