1 /* $NetBSD: asm_tree_dump.c,v 1.1.1.3 2019/12/22 12:34:06 skrll Exp $ */
2
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 /*
5 * libfdt - Flat Device Tree manipulation
6 * Tests if an asm tree built into a shared object matches a given dtb
7 * Copyright (C) 2008 David Gibson, IBM Corporation.
8 */
9
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdint.h>
14 #include <errno.h>
15
16 #include <dlfcn.h>
17
18 #include <libfdt.h>
19
20 #include "tests.h"
21 #include "testdata.h"
22
main(int argc,char * argv[])23 int main(int argc, char *argv[])
24 {
25 void *sohandle;
26 void *fdt;
27 int err;
28
29 test_init(argc, argv);
30 if (argc != 3)
31 CONFIG("Usage: %s <so file> <dtb file>", argv[0]);
32
33 sohandle = dlopen(argv[1], RTLD_NOW);
34 if (!sohandle)
35 FAIL("Couldn't dlopen() %s", argv[1]);
36
37 fdt = dlsym(sohandle, "dt_blob_start");
38 if (!fdt)
39 FAIL("Couldn't locate \"dt_blob_start\" symbol in %s",
40 argv[1]);
41
42 err = fdt_check_header(fdt);
43 if (err != 0)
44 FAIL("%s contains invalid tree: %s", argv[1],
45 fdt_strerror(err));
46
47 save_blob(argv[2], fdt);
48
49 PASS();
50 }
51