Post AXh4X7FUXjaf7LyNqy by enkiv2@eldritch.cafe
(DIR) More posts by enkiv2@eldritch.cafe
(DIR) Post #AXf1TCJL5mVzTqID8C by vertigo@hackers.town
2023-07-13T18:06:17Z
0 likes, 0 repeats
Really getting sick and tired of the "you can't share code if it's statically linked" mantra.It's a lie that has been spoken so many times that it has taken on the status of truth.But there exists one very significant falsification to that mantra -- AmigaOS.This is my yearly reminder to people, it seems, to study exec.library and how OpenLibrary() works. Everything's there.
(DIR) Post #AXf1TCzAaFyXZZrcKe by enkiv2@eldritch.cafe
2023-07-13T18:18:51Z
0 likes, 1 repeats
@vertigo i'll have to dig into this; there are certainly mechanisms for code sharing that do not involve dynamic linking (like message passing & interrupt service routines) but i'm struggling to imagine a code-sharing mechanism based on linking that's not a variation on dynamic linking (even if it's static linking plus a kind of emulation of dynamic linking)...
(DIR) Post #AXh4X6Q5cqTQXvvKjY by vertigo@hackers.town
2023-07-13T18:33:30Z
0 likes, 0 repeats
@enkiv2 It's the same principle as how COM interfaces and C++ v-tables work.A library exposes a jump-table to other programs. Clients of a library invoke OpenLibrary() to get a pointer to what's called a "library base" pointer. Hence why in AmigaOS programs, you find variables like IntuitionBase, GraphicsBase, or DosBase, etc. Once you have this base pointer, you can invoke library functions by relative displacement from this pointer. In assembly language, this would look like this:move.l param1,a0move.l param2,d0move.l myLibraryBase,a6jsr _LVOmyProcedure(a6)LVO stands for Library Vector Offset.One way or another, a library constructs this jump table relative to this base pointer at start-up. This can be done at run-time (with some difficulty), but 99.9999% of libraries just embed this jump table as a static code chunk which is relocated at load-time. You almost never have to think about it.The only reason it's not 100% of the time is because expansion.library has some runtime constraints which aren't satisfied until the whole kernel is up and running (since it technically runs before the kernel is fully up).In this way, programs are statically linked. The libraries are statically linked. But they cooperate at run-time via jump-tables that are established (almost always) at module load time.
(DIR) Post #AXh4X7FUXjaf7LyNqy by enkiv2@eldritch.cafe
2023-07-13T18:39:10Z
0 likes, 0 repeats
@vertigo Oh, ok. Yeah, in my head that's a kind of pseudo-dynamic-linking but I'm sure there's some distinction
(DIR) Post #AXh4X7xnsz2HKmhlvE by vertigo@hackers.town
2023-07-13T18:42:06Z
0 likes, 0 repeats
@enkiv2 The distinction, really, is that the ABI is 100% independent of any particular programming language. All languages are equally disadvantaged when invoking a library's services, so there's no favoritism. This is what allows ARexx and AmigaBASIC to call upon library functions, relying on a more or less generic "FFI"-like facility (before we gave FFI a name) unique to that language.
(DIR) Post #AXh4X8cZRPe5NDmKSu by WomanCorn@schelling.pt
2023-07-14T18:45:26Z
0 likes, 0 repeats
@vertigo @enkiv2 I haven't done any Amiga work, but this reminds me a bit of (classic) MacOs, which grew up on the same CPUs.How does Amiga handle string parameters? I'm guessing there's some standard everyone uses. (On the Mac it was Pascal strings.)
(DIR) Post #AXh6yxftvsLjROjP0a by vertigo@hackers.town
2023-07-14T19:12:53Z
0 likes, 0 repeats
@WomanCorn @enkiv2 AmigaOS had no explicit standard. Most libraries used NUL-terminated strings, but dos.library used BCPL style strings, which resemble Pascal-formatted strings.