userspace function pointers in the kernel
Quoted 11 lines
The model I'm thinking of for elf32-hppa is along these lines:
o The linker creates a plt entry for all plabel relocs. plt entries for elf32-hppa are a function address, linkage table pointer pair, so there's no need for the dynamic linker to allocate fptrs.
o A dynamic plabel reloc will have the function symbol, and an addend into the plt. This is a rather unusual reloc because the function symbol value is ignored when calculating the final value.
o The dynamic linker builds a list or hash table of function symbols versus plt offsets, and adjusts plabels so that only one plt entry is ever used per function.
This is close to how it works on HP-UX, but we didn't use the table in your third bullet, so it became possible for the dynamic loader to come up with one function descriptor (PLT entry) one time, and a different one the next time.
Another thing you need to watch out for is when a library is dlclosed. Because the PLT entries are allocated when you see the reference -- not the definition -- you may not have a candidate PLT entry in the load module that contains the definition of the function (unless you also allocate PLT entries for all exported symbols). This means that you might be asked to dlclose a library that contains the PLT entry that is currently in use as the official function pointer for a function in another load module. If you go ahead and deallocate the library, you're hosed.
-cary
Quoted 5 lines · Cary Coutant
allocate PLT entries for all exported symbols). This means that you might be asked to dlclose a library that contains the PLT entry that is currently in use as the official function pointer for a function in another load module. If you go ahead and deallocate the library, you're hosed.
Yup, another reason, this one really solid, to use David's dynamically allocated fptrs.
Note to David: Make sure dl-fptr.c:_dl_unmap doesn't have this same problem, if this function is called on a dlcose.
Alan
Signature · 1 line
Linuxcare. Support for the Revolution.