Re-work dynamic linkage code

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>