Debian Codegraph @

src/lib/libdwarfp/dwarf_pro_section.h

raw
1 /*
2
3 Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
4 Portions (C) 2016 David Anderson . All Rights Reserved.
5
6 This program is free software; you can redistribute it
7 and/or modify it under the terms of version 2.1 of the
8 GNU Lesser General Public License as published by the Free
9 Software Foundation.
10
11 This program is distributed in the hope that it would be
12 useful, but WITHOUT ANY WARRANTY; without even the implied
13 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE.
15
16 Further, this software is distributed without any warranty
17 that it is free of the rightful claim of any third person
18 regarding infringement or the like. Any license provided
19 herein, whether implied or otherwise, applies only to this
20 software file. Patent licenses, if any, provided herein
21 do not apply to combinations of this program with other
22 software, or any other product whatsoever.
23
24 You should have received a copy of the GNU Lesser General
25 Public License along with this program; if not, write the
26 Free Software Foundation, Inc., 51 Franklin Street - Fifth
27 Floor, Boston MA 02110-1301, USA.
28 */
29
30 /* relocation section names */
31 extern const char *_dwarf_rel_section_names[];
32
33 /* section names */
34 extern const char *_dwarf_sectnames[];
35
36 /* struct to hold relocation entries. It is maintained as a linked
37 list of relocation structs, and will then be written at as a
38 whole into the relocation section. Whether its 32 bit or
39 64 bit will be obtained from Dwarf_Debug pointer. */
40
41 /* struct stores a chunk of data pertaining to a section.
42 Following ds_next we find the rest of the data for
43 the section. */
44 struct Dwarf_P_Section_Data_s {
45 int ds_elf_sect_no; /* elf section number */
46 char *ds_data; /* data contained in section */
47 unsigned long ds_nbytes; /* bytes of data used so far */
48 unsigned long ds_orig_alloc; /* bytes allocated originally */
49 Dwarf_P_Section_Data ds_next; /* next on the list */
50 };
51
52 /* Used to allow a dummy initial struct (which we
53 drop before it gets used
54 This must not match any legitimate 'section' number.
55 */
56 #define MAGIC_SECT_NO -3
57
58 /* Size of chunk of data allocated in one alloc
59 Not clear if this is the best size.
60 Used to be just 4096 for user data, the section data struct
61 was a separate malloc.
62 */
63 #define CHUNK_SIZE (4096 - sizeof (struct Dwarf_P_Section_Data_s))
64
65 /*
66 chunk alloc routine -
67 if chunk->ds_data is nil, it will alloc CHUNK_SIZE bytes,
68 and return pointer to the beginning. If chunk is not nil,
69 it will see if there's enoungh space for nbytes in current
70 chunk, if not, add new chunk to linked list, and return
71 a char * pointer to it. Return null if unsuccessful.
72 */
73 Dwarf_Small *_dwarf_pro_buffer(Dwarf_P_Debug dbg, int sectno,
74 unsigned long nbytes);
75
76 /* GET_CHUNK_ERROR is new Sept 2016 to use DW_DLV_ERROR. */
77 #define GET_CHUNK_ERR(dbg,sectno,ptr,nbytes,error) \
78 { \
79 (ptr) = _dwarf_pro_buffer((dbg),(sectno),(nbytes)); \
80 if ((ptr) == NULL) { \
81 DWARF_P_DBG_ERROR(dbg,DW_DLE_CHUNK_ALLOC,DW_DLV_ERROR); \
82 } \
83 }
84 #define GET_CHUNK(dbg,sectno,ptr,nbytes,error) \
85 { \
86 (ptr) = _dwarf_pro_buffer((dbg),(sectno),(nbytes)); \
87 if ((ptr) == NULL) { \
88 DWARF_P_DBG_ERROR(dbg,DW_DLE_CHUNK_ALLOC,-1); \
89 } \
90 }
91
92 int _dwarf_transform_arange_to_disk(Dwarf_P_Debug dbg,
93 Dwarf_Unsigned *nbufs,
94 Dwarf_Error * error);
95
96 /* These are for creating ELF section type codes.
97 We are not trying to match any particulare
98 ABI's settings for section type.
99 In the producer, see de_callback_func() calls.
100
101 If SHT_MIPS_DWARF was defined sometimes
102 that was the value taken: 0x7000001e
103 If it's important to someone then
104 passing in a string like SHT=0x7000001e
105 to the 'extra' argument of dwarf_producer_init()
106 would work nicely (leading/trailing spaces
107 are allowed, as is a NULL pointer instead
108 of a string).
109 One is a convenient default for testing purposes.
110 */
111 #define SECTION_TYPE 1 /* SHT_PROGBITS in Elf. */