Re:Oasis: Small statically-linked Linux system
by waynecochran on Sunday August 14, 2022 @10:45AM
(#32459672)
I understand the motivation for shared libs is the reduced memory footprint for large common libs. I have an alternative idea that avoids the headaches of shared lib mismatches and still can reduce the memory footprint. Have relocatable code be statically linked but stored with a hash. When loading a binary see if common relocatable code is already loaded .. if it has the same hash then it is exactly the same and can be safely shared. No version mismatch headaches.
[ Parent
| on HN ]
Re:Oasis: Small statically-linked Linux system
by cesarb on Sunday August 14, 2022 @11:19AM
(#32459955)
> Have relocatable code be statically linked but stored with a hash. When loading a binary see if common relocatable code is already loaded .. if it has the same hash then it is exactly the same and can be safely shared.
It's not actually "code" which is being shared, but instead the memory pages containing that code (the sharing granularity is a single page, since sharing works by pointing the page table entries on each process to the same physical page). So either you'd have to force page alignment for each and every function (highly wasteful, since the page size is at least 4096 bytes), or you're reinventing shared libraries but using a hash instead of a version.
Re:Oasis: Small statically-linked Linux system
by waynecochran on Sunday August 14, 2022 @01:54PM
(#32461336)
This is not like shared libraries in that my program is guaranteed to load and run regardless of what libs are on the system. Also, I am guaranteed my program is running with the exact same library I tested it with.
Re:Oasis: Small statically-linked Linux system
by waynecochran on Sunday August 14, 2022 @11:39AM
(#32460145)
That's finer grained than I imagined. I am assuming hashes for large pieces of code that are completely relocatable in memory.
Re:Oasis: Small statically-linked Linux system
by 8organicbits on Sunday August 14, 2022 @11:24AM
(#32460004)
I think often the binaries will have been compiled against slightly different versions. With dynamic linking, I can swap 1.0.1 for 1.0.2 or 1.0.3 without issue. The hash would require an exact match, which is likely rare.
Re:Oasis: Small statically-linked Linux system
by waynecochran on Sunday August 14, 2022 @11:42AM
(#32460178)
I want an exact match. That is what I developed and tested against. A change, however small, can have unintended consequences. Changing versions is a huge issue from a reliability point of view.