tools/debugedit.c File Reference

#include <assert.h>
#include <byteswap.h>
#include <endian.h>
#include <errno.h>
#include <error.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <popt.h>
#include <gelf.h>
#include <dwarf.h>
#include "hashtab.h"

Go to the source code of this file.

Data Structures

struct  DSO
struct  REL
struct  abbrev_attr
struct  abbrev_tag

Defines

#define _FILE_OFFSET_BITS   64
#define DW_TAG_partial_unit   0x3c
#define read_uleb128(ptr)
#define read_1(ptr)   *ptr++
#define read_16(ptr)
#define read_32(ptr)
#define do_read_32_relocated(ptr)
#define read_32_relocated(ptr)
#define DEBUG_INFO   0
#define DEBUG_ABBREV   1
#define DEBUG_LINE   2
#define DEBUG_ARANGES   3
#define DEBUG_PUBNAMES   4
#define DEBUG_MACINFO   5
#define DEBUG_LOC   6
#define DEBUG_STR   7
#define DEBUG_FRAME   8
#define DEBUG_RANGES   9
#define IS_DIR_SEPARATOR(c)   ((c)=='/')

Typedefs

typedef unsigned int uint_32
typedef unsigned short uint_16

Functions

static uint_16 buf_read_ule16 (unsigned char *data)
static uint_16 buf_read_ube16 (unsigned char *data)
static uint_32 buf_read_ule32 (unsigned char *data)
static uint_32 buf_read_ube32 (unsigned char *data)
static const char * strptr (DSO *dso, int sec, off_t offset)
static void dwarf2_write_le32 (unsigned char *p, GElf_Addr val)
static void dwarf2_write_be32 (unsigned char *p, GElf_Addr val)
static hashval_t abbrev_hash (const void *p)
static int abbrev_eq (const void *p, const void *q)
static void abbrev_del (void *p)
static htab_t read_abbrev (DSO *dso, unsigned char *ptr)
static char * canonicalize_path (char *s, char *d)
static int has_prefix (const char *str, const char *prefix)
static int edit_dwarf2_line (DSO *dso, uint_32 off, char *comp_dir, int phase)
static unsigned char * edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
static int rel_cmp (const void *a, const void *b)
static int edit_dwarf2 (DSO *dso)
static DSOfdopen_dso (int fd, const char *name)
int main (int argc, char *argv[])

Variables

char * base_dir = NULL
char * dest_dir = NULL
char * list_file = NULL
int list_file_fd = -1
static uint_16(*) do_read_16 (unsigned char *ptr)
static uint_32(*) do_read_32 (unsigned char *ptr)
static void(*) write_32 (unsigned char *ptr, GElf_Addr val)
static int ptr_size
RELrelptr
RELrelend
int reltype
struct {
   const char *   name
   unsigned char *   data
   Elf_Data *   elf_data
   size_t   size
   int   sec
   int   relsec
debug_sections []
static struct poptOption optionsTable []


Define Documentation

#define _FILE_OFFSET_BITS   64

Definition at line 20 of file debugedit.c.

#define DEBUG_ABBREV   1

#define DEBUG_ARANGES   3

#define DEBUG_FRAME   8

#define DEBUG_INFO   0

#define DEBUG_LINE   2

Referenced by edit_dwarf2_line().

#define DEBUG_LOC   6

#define DEBUG_MACINFO   5

#define DEBUG_PUBNAMES   4

#define DEBUG_RANGES   9

#define DEBUG_STR   7

Referenced by edit_attributes(), and edit_dwarf2_line().

#define do_read_32_relocated ( ptr   ) 

Value:

({                      \
  uint_32 dret = do_read_32 (ptr);                      \
  if (relptr)                                           \
    {                                                   \
      while (relptr < relend && relptr->ptr < ptr)      \
        ++relptr;                                       \
      if (relptr < relend && relptr->ptr == ptr)        \
        {                                               \
          if (reltype == SHT_REL)                       \
            dret += relptr->addend;                     \
          else                                          \
            dret = relptr->addend;                      \
        }                                               \
    }                                                   \
  dret;                                                 \
})

Definition at line 153 of file debugedit.c.

Referenced by edit_attributes().

#define DW_TAG_partial_unit   0x3c

Definition at line 41 of file debugedit.c.

Referenced by edit_attributes().

#define IS_DIR_SEPARATOR (  )     ((c)=='/')

Definition at line 343 of file debugedit.c.

Referenced by canonicalize_path().

#define read_1 ( ptr   )     *ptr++

Definition at line 136 of file debugedit.c.

#define read_16 ( ptr   ) 

Value:

({                                      \
  uint_16 ret = do_read_16 (ptr);                       \
  ptr += 2;                                             \
  ret;                                                  \
})

Definition at line 138 of file debugedit.c.

Referenced by edit_attributes(), and edit_dwarf2_line().

#define read_32 ( ptr   ) 

Value:

({                                      \
  uint_32 ret = do_read_32 (ptr);                       \
  ptr += 4;                                             \
  ret;                                                  \
})

Definition at line 144 of file debugedit.c.

Referenced by edit_attributes(), and edit_dwarf2_line().

#define read_32_relocated ( ptr   ) 

Value:

({                      \
  uint_32 ret = do_read_32_relocated (ptr);             \
  ptr += 4;                                             \
  ret;                                                  \
})

Definition at line 170 of file debugedit.c.

#define read_uleb128 ( ptr   ) 

Value:

({              \
  unsigned int ret = 0;                 \
  unsigned int c;                       \
  int shift = 0;                        \
  do                                    \
    {                                   \
      c = *ptr++;                       \
      ret |= (c & 0x7f) << shift;       \
      shift += 7;                       \
    } while (c & 0x80);                 \
                                        \
  if (shift >= 35)                      \
    ret = UINT_MAX;                     \
  ret;                                  \
})

Definition at line 67 of file debugedit.c.

Referenced by edit_attributes(), edit_dwarf2_line(), and read_abbrev().


Typedef Documentation

typedef unsigned short uint_16

Definition at line 49 of file debugedit.c.

typedef unsigned int uint_32

Definition at line 48 of file debugedit.c.


Function Documentation

static void abbrev_del ( void *  p  )  [static]

Definition at line 263 of file debugedit.c.

Referenced by read_abbrev().

static int abbrev_eq ( const void *  p,
const void *  q 
) [static]

Definition at line 254 of file debugedit.c.

References abbrev_tag::entry.

Referenced by read_abbrev().

static hashval_t abbrev_hash ( const void *  p  )  [static]

Definition at line 246 of file debugedit.c.

References abbrev_tag::entry.

Referenced by read_abbrev().

static uint_16 buf_read_ube16 ( unsigned char *  data  )  [inline, static]

Definition at line 96 of file debugedit.c.

static uint_32 buf_read_ube32 ( unsigned char *  data  )  [inline, static]

Definition at line 108 of file debugedit.c.

static uint_16 buf_read_ule16 ( unsigned char *  data  )  [inline, static]

Definition at line 90 of file debugedit.c.

static uint_32 buf_read_ule32 ( unsigned char *  data  )  [inline, static]

Definition at line 102 of file debugedit.c.

static char* canonicalize_path ( char *  s,
char *  d 
) [static]

Definition at line 346 of file debugedit.c.

References IS_DIR_SEPARATOR.

Referenced by edit_dwarf2_line().

static void dwarf2_write_be32 ( unsigned char *  p,
GElf_Addr  val 
) [static]

Definition at line 189 of file debugedit.c.

static void dwarf2_write_le32 ( unsigned char *  p,
GElf_Addr  val 
) [static]

Definition at line 177 of file debugedit.c.

static unsigned char* edit_attributes ( DSO dso,
unsigned char *  ptr,
struct abbrev_tag t,
int  phase 
) [static]

Definition at line 687 of file debugedit.c.

References abbrev_attr::attr, abbrev_tag::attr, base_dir, data, debug_sections, DEBUG_STR, dest_dir, do_read_32_relocated, DW_TAG_partial_unit, elf_data, DSO::filename, abbrev_attr::form, has_prefix(), name, abbrev_tag::nattr, ptr_size, read_16, read_32, read_uleb128, and abbrev_tag::tag.

static int edit_dwarf2 ( DSO dso  )  [static]

Definition at line 874 of file debugedit.c.

References data, debug_sections, DSO::ehdr, DSO::filename, name, ptr_size, DSO::scn, DSO::shdr, and strptr().

Referenced by main().

static int edit_dwarf2_line ( DSO dso,
uint_32  off,
char *  comp_dir,
int  phase 
) [static]

Definition at line 451 of file debugedit.c.

References alloca(), base_dir, canonicalize_path(), DEBUG_LINE, debug_sections, DEBUG_STR, dest_dir, elf_data, EXIT_FAILURE, file, DSO::filename, has_prefix(), list_file_fd, read_16, read_32, read_uleb128, and size.

static DSO* fdopen_dso ( int  fd,
const char *  name 
) [static]

Definition at line 1190 of file debugedit.c.

References DSO::ehdr, DSO::elf, DSO::filename, DSO::scn, and DSO::shdr.

Referenced by main().

static int has_prefix ( const char *  str,
const char *  prefix 
) [static]

Definition at line 435 of file debugedit.c.

Referenced by edit_attributes(), and edit_dwarf2_line().

int main ( int  argc,
char *  argv[] 
)

Definition at line 1265 of file debugedit.c.

References base_dir, dest_dir, edit_dwarf2(), DSO::ehdr, errno, fdopen_dso(), file, list_file, list_file_fd, name, DSO::shdr, strerror, and strptr().

static htab_t read_abbrev ( DSO dso,
unsigned char *  ptr 
) [static]

Definition at line 269 of file debugedit.c.

References abbrev_del(), abbrev_eq(), abbrev_hash(), abbrev_tag::attr, DSO::filename, htab_delete(), htab_find_slot(), htab_try_create(), INSERT, read_uleb128, and size.

static int rel_cmp ( const void *  a,
const void *  b 
) [static]

Definition at line 860 of file debugedit.c.

References REL::ptr.

static const char* strptr ( DSO dso,
int  sec,
off_t  offset 
) [static]

Definition at line 114 of file debugedit.c.

References data, and DSO::scn.

Referenced by edit_dwarf2(), and main().


Variable Documentation

char* base_dir = NULL

Definition at line 43 of file debugedit.c.

Referenced by edit_attributes(), edit_dwarf2_line(), and main().

unsigned char* data

Definition at line 202 of file debugedit.c.

Referenced by cacheContainsDirectory(), db3cdel(), db3cget(), db3cpget(), db3cput(), db_join(), db_put(), dbg_keyval(), dbiDel(), dbiFindByLabel(), dbiFindMatches(), dbiGet(), dbiPget(), dbiPut(), dbt2set(), edit_attributes(), edit_dwarf2(), ftpAbort(), ftpFileDone(), ftpReq(), hdr_subscript(), miFreeHeader(), open_dso(), rpmdbAdd(), rpmdbCountPackages(), rpmdbFindByFile(), rpmdbFindFpList(), rpmdbGrowIterator(), rpmdbInitIterator(), rpmdbNextIterator(), rpmdbRemove(), rpmfcELF(), rpmts_GetKeys(), set2dbt(), sql_bind_data(), sql_cdel(), sql_cget(), sql_cput(), strptr(), and unsatisfiedDepend().

struct { ... } debug_sections[] [static]

Referenced by edit_attributes(), edit_dwarf2(), and edit_dwarf2_line().

char* dest_dir = NULL

Definition at line 44 of file debugedit.c.

Referenced by edit_attributes(), edit_dwarf2_line(), and main().

uint_16(*) do_read_16(unsigned char *ptr) [static]

Definition at line 83 of file debugedit.c.

uint_32(*) do_read_32(unsigned char *ptr) [static]

Definition at line 84 of file debugedit.c.

Elf_Data* elf_data

Definition at line 203 of file debugedit.c.

Referenced by edit_attributes(), and edit_dwarf2_line().

char* list_file = NULL

Definition at line 45 of file debugedit.c.

Referenced by main().

int list_file_fd = -1

Definition at line 46 of file debugedit.c.

Referenced by edit_dwarf2_line(), and main().

const char* name

Definition at line 201 of file debugedit.c.

struct poptOption optionsTable[] [static]

Initial value:

 {
    { "base-dir",  'b', POPT_ARG_STRING, &base_dir, 0,
      "base build directory of objects", NULL },
    { "dest-dir",  'd', POPT_ARG_STRING, &dest_dir, 0,
      "directory to rewrite base-dir into", NULL },
    { "list-file",  'l', POPT_ARG_STRING, &list_file, 0,
      "file where to put list of source and header file names", NULL },
      POPT_AUTOHELP
    { NULL, 0, 0, NULL, 0, NULL, NULL }
}

Definition at line 1178 of file debugedit.c.

int ptr_size [static]

Definition at line 87 of file debugedit.c.

Referenced by edit_attributes(), and edit_dwarf2().

REL * relend

Definition at line 150 of file debugedit.c.

REL* relptr

Definition at line 150 of file debugedit.c.

int relsec

Definition at line 205 of file debugedit.c.

int reltype

Definition at line 151 of file debugedit.c.

int sec

Definition at line 205 of file debugedit.c.

size_t size

Definition at line 204 of file debugedit.c.

Referenced by doReadRC(), DumpString(), edit_dwarf2_line(), find_empty_slot_for_expand(), htab_find_slot_with_hash(), htab_find_with_hash(), LoadCode(), LoadLines(), LoadString(), luaF_freeclosure(), luaZ_fill(), read_abbrev(), readIcon(), rpmalAdd(), rpmfiBuildFNames(), rpmioSlurp(), rpmVerifyFile(), setnodevector(), verifyHeader(), verifySizeSignature(), and xstrdup().

void(*) write_32(unsigned char *ptr, GElf_Addr val) [static]

Definition at line 85 of file debugedit.c.


Generated on Tue Feb 19 22:27:09 2008 for rpm by  doxygen 1.5.1