/* Record any useful information in transfer vector entry and display it in human-readable form using the plugin API message() callback. */ enum ld_plugin_status parse_and_dump_tv_tag (size_t n, struct ld_plugin_tv *tv) { enum ld_plugin_status rv = parse_tv_tag (tv); dump_tv_tag (n, tv); return rv; }
/* Standard plugin API entry point. */ enum ld_plugin_status onload (struct ld_plugin_tv *tv) { enum ld_plugin_status rv; /* This plugin does nothing but dump the tv array. It would be an error if this function was called without one. */ if (!tv) return LDPS_ERR; /* First entry should always be LDPT_MESSAGE, letting us get hold of it easily so we can send output straight away. */ if (tv[0].tv_tag == LDPT_MESSAGE) tv_message = tv[0].tv_u.tv_message; do if ((rv = parse_tv_tag (tv)) != LDPS_OK) return rv; while ((tv++)->tv_tag != LDPT_NULL); /* Register hooks only if instructed by options. */ if (register_claimfile_hook) { if (!tv_register_claim_file) { TV_MESSAGE (LDPL_FATAL, "No register_claim_file hook"); fflush (NULL); return LDPS_ERR; } (*tv_register_claim_file) (onclaim_file); } if (register_allsymbolsread_hook) { if (!tv_register_all_symbols_read) { TV_MESSAGE (LDPL_FATAL, "No register_all_symbols_read hook"); fflush (NULL); return LDPS_ERR; } (*tv_register_all_symbols_read) (onall_symbols_read); } if (register_cleanup_hook) { if (!tv_register_cleanup) { TV_MESSAGE (LDPL_FATAL, "No register_cleanup hook"); fflush (NULL); return LDPS_ERR; } (*tv_register_cleanup) (oncleanup); } /* Claim testsuite/ld-plugin/func.c, standalone or in a library. Its size must be SIZE_OF_FUNC_C bytes. */ #define SIZE_OF_FUNC_C 248 if (onload_ret == LDPS_OK && (record_claim_file ("func.c", SIZE_OF_FUNC_C) != LDPS_OK || record_claimed_file_symbol ("func::0:0:0") != LDPS_OK || record_claimed_file_symbol ("_func::0:0:0") != LDPS_OK || record_claim_file ("libfunc.a", SIZE_OF_FUNC_C) != LDPS_OK || record_claimed_file_symbol ("func::0:0:0") != LDPS_OK || record_claimed_file_symbol ("_func::0:0:0") != LDPS_OK)) onload_ret = LDPS_ERR; return onload_ret; }