Debian Codegraph @

src/lib/libdwarf/dwarf_object_detector.h

raw
1 /* Copyright (c) 2018-2023, David Anderson
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with
5 or without modification, are permitted provided that the
6 following conditions are met:
7
8 Redistributions of source code must retain the above
9 copyright notice, this list of conditions and the following
10 disclaimer.
11
12 Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following
14 disclaimer in the documentation and/or other materials
15 provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef DWARF_OBJECT_DETECTOR_H
33 #define DWARF_OBJECT_DETECTOR_H
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39 /* Declares the interface function.
40 outpath is a place you provide, of a length outpath_len
41 you consider reasonable,
42 where the final path used is recorded.
43 outpath_len must be larger than strlen(path);
44
45 This matters as for mach-o if the path is a directory
46 name the function will look in the standard macho-place
47 for the object file (useful for dSYM) and return the
48 constructed path in oupath.
49 returns DW_DLV_OK, DW_DLV_ERROR, or DW_DLV_NO_ENTRY */
50
51 #ifndef DW_FTYPE_UNKNOWN
52 #define DW_FTYPE_UNKNOWN 0
53 #define DW_FTYPE_ELF 1
54 #define DW_FTYPE_MACH_O 2
55 #define DW_FTYPE_PE 3
56 #define DW_FTYPE_ARCHIVE 4 /* unix archive */
57 #endif /* DW_FTYPE_UNKNOWN */
58
59 /* offsetsize refers to the object-file-format.
60 Elf 32 or macho-32 or PE 32, for example.
61 Not to DWARF offset sizes. */
62
63 /* Path means look(first) for an dynsym object
64 of the same name per MacOS standards,
65 making the outpath space needed is more than
66 that in path.
67 Copies the actual path into outpath, (an error
68 if the length in outpath_len is less than needed
69 for the object found).
70 If DW_DLV_NO_ENTRY or DW_DLV_ERROR returned
71 the argument values other than path
72 must be considered to be in an unknown state. */
73
74 /* The errcode is a small integer distinct from libdwarf
75 and simply printing the integer (returned through
76 *errcode when the function returns DW_DLV_ERROR)
77 will hopefully suffice for most purposes. */
78
79 /* Added September 2023 for Mach-O universal binaries */
80 int _dwarf_object_detector_fd_a(int dw_fd,
81 unsigned int *dw_ftype,
82 unsigned int *dw_endian,
83 unsigned int *dw_offsetsize,
84 Dwarf_Unsigned dw_offset_base,
85 Dwarf_Unsigned *dw_filesize,
86 int *dw_errcode);
87
88 #ifdef __cplusplus
89 }
90 #endif /* __cplusplus */
91 #endif /* DWARF_OBJECT_DETECTOR_H */