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