#include <sys/types.h>
#include <sys/linker.h>

#include <stdio.h>
#include <stdint.h>
#include <string.h>

int
main(int argc, char **argv)
{
	struct kld_sym_lookup lookup;
	int failed;

	if (argc < 2) {
		fprintf(stderr, "usage: SMOKE-kldsym SYMBOL...\n");
		return (2);
	}
	failed = 0;
	for (int index = 1; index < argc; ++index) {
		memset(&lookup, 0, sizeof(lookup));
		lookup.version = sizeof(lookup);
		lookup.symname = argv[index];
		if (kldsym(0, KLDSYM_LOOKUP, &lookup) == -1) {
			printf("MISSING %s\n", argv[index]);
			failed = 1;
		} else {
			printf("PRESENT %s 0x%jx\n", argv[index],
			    (uintmax_t)lookup.symvalue);
		}
	}
	return (failed);
}
