Next: , Previous: geta4, Up: Top

9 Library base pointers - and how they work

The model of shared libraries on the amiga works as follows:

The library is not managed by the linker but by the application. You open it through a system function. The advantage of this is clear: You open libraries under program control, i.e. you can even check if they are there and disable some features if not or take other action.

The result of this system function is a pointer to the upper end of a jump table (a table of ‘jmp’ instructions to the different functions) and the lower end of a library structure containing extra information for every library you opened. These pointers are called library base pointers. They are usually stored in normal global variables.

To call a system function you have to put the library base into address register a6 and the parameters into certain other registers. Then your program has to jump over the certain address of the jump table. The function returns with the result in register d0 (and sometimes some more).

A compiler can handle this behaviour by two different methods:

Both methods require to access the library base pointer (and a valid value in it) so they make up a reference to this variable.