Implement R_PDB loading in bfd

We disable symbol_file_add_separate for now so the old symbol loading
still works.
This commit is contained in:
Les De Ridder 2020-07-12 14:35:26 +02:00
parent 995f44ff35
commit dcae9fd7d7
5 changed files with 55 additions and 6 deletions

View File

@ -210,7 +210,7 @@ AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
DEFAULT_INCLUDES = -I.@am__isrc@ -I/usr/include/libr
depcomp = $(SHELL) $(top_srcdir)/../depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f

View File

@ -6,7 +6,7 @@
bfd_boolean
bfd_pdb_close_and_cleanup (bfd *abfd)
{
return FALSE;
return TRUE;
}
/* Ask the BFD to free all cached information. */
@ -89,9 +89,51 @@ bfd_pdb_find_nearest_line (bfd *abfd,
#define bfd_pdb_read_minisymbols _bfd_generic_read_minisymbols
#define bfd_pdb_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
static st64
r_buffer_read (RBuffer *buffer, ut8 *out, ut64 length)
{
bfd *abfd = buffer->priv;
return abfd->iovec->bread (abfd, out, length);
}
static st64
r_buffer_seek (RBuffer *buffer, st64 address, int whence)
{
bfd *abfd = buffer->priv;
return abfd->iovec->bseek (abfd, address, whence);
}
static bfd_pdb_data_struct *
get_bfd_pdb_data (bfd *abfd)
{
RBufferMethods *buffer_methods = bfd_zalloc (abfd, sizeof (RBufferMethods));
buffer_methods->read = &r_buffer_read;
buffer_methods->seek = &r_buffer_seek;
RBuffer *r_buffer = bfd_zalloc (abfd, sizeof (RBuffer));
r_buffer->methods = buffer_methods;
r_buffer->priv = abfd;
r_buffer->readonly = TRUE;
R_PDB *pdb = bfd_zalloc (abfd, sizeof (R_PDB));
if (init_pdb_parser_with_buf (pdb, r_buffer))
{
bfd_pdb_data_struct *result = bfd_alloc (abfd, sizeof (bfd_pdb_data_struct));
result->pdb = pdb;
return result;
}
return NULL;
}
const bfd_target *
bfd_pdb_check_format (bfd *abfd)
{
if ((abfd->tdata.pdb_data = get_bfd_pdb_data (abfd)))
{
return abfd->xvec;
}
bfd_set_error (bfd_error_wrong_format);
return NULL;
}

View File

@ -2,4 +2,11 @@
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
#include "libbfd.h"
#include <libr/r_pdb.h>
typedef struct pdb_data_struct
{
R_PDB* pdb;
} bfd_pdb_data_struct;

View File

@ -732,8 +732,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
gdb_bfd_ref_ptr debug_bfd (try_load_pdb_bfd (objfile));
if (debug_bfd.get ())
{
symbol_file_add_separate (debug_bfd.get (), debug_bfd->filename,
symfile_flags, objfile);
//symbol_file_add_separate (debug_bfd.get (), debug_bfd->filename,
// symfile_flags, objfile);
}
}
}

View File

@ -238,7 +238,7 @@ get_pdb_paths (struct objfile *objfile)
auto codeview_pdb_path = get_codeview_pdb_path (objfile);
if (!codeview_pdb_path)
return paths;
return paths; //if there is no CodeView PDB path, we assume no PDB exists
paths.push_back (*codeview_pdb_path);
paths.push_back ("target:" + *codeview_pdb_path);