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