ReactOS  0.4.14-dev-552-g2fad488
dwarfaranges.c
Go to the documentation of this file.
1 /*
2  * Dwarf address ranges parsing code.
3  */
4 
5 #define NTOSAPI
6 #include <ntddk.h>
7 #include <reactos/rossym.h>
8 #include "rossympriv.h"
9 #include <ntimage.h>
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 #include "dwarf.h"
15 
16 int
18 {
19  DwarfBuf b;
20  int segsize, i;
21  ulong len, id, off, base, size;
22  uchar *start, *end;
23 
24  memset(&b, 0, sizeof b);
25  b.d = d;
26  b.p = d->aranges.data;
27  b.ep = b.p + d->aranges.len;
28 
29  while(b.p < b.ep){
30  start = b.p;
31  len = dwarfget4(&b);
32  if (!len) { b.ep = b.p - 4; return -1; }
33  if((id = dwarfget2(&b)) != 2){
34  if(b.p == nil){
35  underflow:
36  werrstr("buffer underflow reading address ranges header");
37  }else
38  werrstr("bad dwarf version 0x%x in address ranges header", id);
39  return -1;
40  }
41  off = dwarfget4(&b);
42  b.addrsize = dwarfget1(&b);
43  if(d->addrsize == 0)
44  d->addrsize = b.addrsize;
45  segsize = dwarfget1(&b);
46  USED(segsize); /* what am i supposed to do with this? */
47  if(b.p == nil)
48  goto underflow;
49  if((i = (b.p-start) % (2*b.addrsize)) != 0)
50  b.p += 2*b.addrsize - i;
51  end = start+4+len;
52  while(b.p!=nil && b.p<end){
53  base = dwarfgetaddr(&b);
54  size = dwarfgetaddr(&b);
55  if (!size) continue;
56  if(b.p == nil)
57  goto underflow;
58  if(base <= addr && addr < base+size){
59  *unit = off;
60  return 0;
61  }
62  }
63  if(b.p == nil)
64  goto underflow;
65  b.p = end;
66  }
67  werrstr("address 0x%lux is not listed in dwarf debugging symbols", addr);
68  return -1;
69 }
70 
71 
#define werrstr(str,...)
Definition: compat.h:34
unsigned char uchar
Definition: Unfrag.h:59
ulong dwarfget4(DwarfBuf *)
Definition: dwarfget.c:96
GLuint GLuint end
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ulong dwarfget1(DwarfBuf *)
Definition: dwarfget.c:18
GLuint base
Definition: 3dtext.c:35
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLsizeiptr size
Definition: glext.h:5919
#define d
Definition: ke_i.h:81
ulong dwarfget2(DwarfBuf *)
Definition: dwarfget.c:82
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
#define USED(x)
Definition: compat.h:38
unsigned long ulong
Definition: linux.h:275
GLuint start
Definition: gl.h:1545
Definition: dwarf.h:436
#define nil
Definition: compat.h:23
GLenum GLuint id
Definition: glext.h:5579
int dwarfaddrtounit(Dwarf *d, ulong addr, ulong *unit)
Definition: dwarfaranges.c:17
#define memset(x, y, z)
Definition: compat.h:39
ulong dwarfgetaddr(DwarfBuf *)
Definition: dwarfget.c:124
off
Definition: i386-dis.c:3909