/* PEF support for BFD.
- Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
- 2009, 2011 Free Software Foundation, Inc.
+ Copyright (C) 1999-2017 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
#define bfd_pef_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
#define bfd_pef_get_lineno _bfd_nosymbols_get_lineno
#define bfd_pef_find_nearest_line _bfd_nosymbols_find_nearest_line
+#define bfd_pef_find_line _bfd_nosymbols_find_line
#define bfd_pef_find_inliner_info _bfd_nosymbols_find_inliner_info
+#define bfd_pef_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string
#define bfd_pef_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
#define bfd_pef_read_minisymbols _bfd_generic_read_minisymbols
#define bfd_pef_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
#define bfd_pef_section_already_linked _bfd_generic_section_already_linked
#define bfd_pef_bfd_define_common_symbol bfd_generic_define_common_symbol
#define bfd_pef_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define bfd_pef_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
#define bfd_pef_bfd_link_add_symbols _bfd_generic_link_add_symbols
#define bfd_pef_bfd_link_just_syms _bfd_generic_link_just_syms
#define bfd_pef_bfd_copy_link_hash_symbol_type \
#define bfd_pef_bfd_final_link _bfd_generic_final_link
#define bfd_pef_bfd_link_split_section _bfd_generic_link_split_section
#define bfd_pef_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
+#define bfd_pef_bfd_link_check_relocs _bfd_generic_link_check_relocs
static int
bfd_pef_parse_traceback_table (bfd *abfd,
fprintf (file, " %-5s %s", symbol->section->name, symbol->name);
if (CONST_STRNEQ (symbol->name, "__traceback_"))
{
- unsigned char *buf = alloca (symbol->udata.i);
+ unsigned char *buf = xmalloc (symbol->udata.i);
size_t offset = symbol->value + 4;
size_t len = symbol->udata.i;
int ret;
len, 0, NULL, file);
if (ret < 0)
fprintf (file, " [ERROR]");
+ free (buf);
}
}
}
goto end;
for (section = abfd->sections; section != NULL; section = section->next)
- if ((section->index + 1) == header.main_section)
+ if ((long) (section->index + 1) == header.main_section)
break;
if (section == NULL)
}
int
-bfd_pef_scan (abfd, header, mdata)
- bfd *abfd;
- bfd_pef_header *header;
- bfd_pef_data_struct *mdata;
+bfd_pef_scan (bfd *abfd,
+ bfd_pef_header *header,
+ bfd_pef_data_struct *mdata)
{
unsigned int i;
enum bfd_architecture cputype;
bfd_pef_convert_architecture (header->architecture, &cputype, &cpusubtype);
if (cputype == bfd_arch_unknown)
{
- (*_bfd_error_handler) (_("bfd_pef_scan: unknown architecture 0x%lx"),
- header->architecture);
+ _bfd_error_handler (_("bfd_pef_scan: unknown architecture 0x%lx"),
+ header->architecture);
return -1;
}
bfd_set_arch_mach (abfd, cputype, cpusubtype);
static const bfd_target *
bfd_pef_object_p (bfd *abfd)
{
- struct bfd_preserve preserve;
bfd_pef_header header;
+ bfd_pef_data_struct *mdata;
- preserve.marker = NULL;
if (bfd_pef_read_header (abfd, &header) != 0)
goto wrong;
if (header.tag1 != BFD_PEF_TAG1 || header.tag2 != BFD_PEF_TAG2)
goto wrong;
- preserve.marker = bfd_zalloc (abfd, sizeof (bfd_pef_data_struct));
- if (preserve.marker == NULL
- || !bfd_preserve_save (abfd, &preserve))
+ mdata = (bfd_pef_data_struct *) bfd_zalloc (abfd, sizeof (*mdata));
+ if (mdata == NULL)
goto fail;
- if (bfd_pef_scan (abfd, &header,
- (bfd_pef_data_struct *) preserve.marker) != 0)
+ if (bfd_pef_scan (abfd, &header, mdata))
goto wrong;
- bfd_preserve_finish (abfd, &preserve);
return abfd->xvec;
wrong:
bfd_set_error (bfd_error_wrong_format);
fail:
- if (preserve.marker != NULL)
- bfd_preserve_restore (abfd, &preserve);
return NULL;
}
static int
bfd_pef_xlib_read_header (bfd *abfd, bfd_pef_xlib_header *header)
{
- unsigned char buf[76];
+ unsigned char buf[80];
bfd_seek (abfd, 0, SEEK_SET);
- if (bfd_bread ((void *) buf, 76, abfd) != 76)
+ if (bfd_bread ((void *) buf, sizeof buf, abfd) != sizeof buf)
return -1;
header->tag1 = bfd_getb32 (buf);
static const bfd_target *
bfd_pef_xlib_object_p (bfd *abfd)
{
- struct bfd_preserve preserve;
bfd_pef_xlib_header header;
if (bfd_pef_xlib_read_header (abfd, &header) != 0)
return NULL;
}
- if (! bfd_preserve_save (abfd, &preserve))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
if (bfd_pef_xlib_scan (abfd, &header) != 0)
{
- bfd_preserve_restore (abfd, &preserve);
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- bfd_preserve_finish (abfd, &preserve);
return abfd->xvec;
}