* peicode.h: Add & 0xffffffff when using ImageBase in case bfd_vma
is 64 bits.
This commit is contained in:
parent
e18683b73b
commit
d2d70da54f
2 changed files with 108 additions and 40 deletions
|
@ -1,9 +1,14 @@
|
||||||
|
Wed May 21 17:15:50 1997 Ian Lance Taylor <ian@cygnus.com>
|
||||||
|
|
||||||
|
* peicode.h: Add & 0xffffffff when using ImageBase in case bfd_vma
|
||||||
|
is 64 bits.
|
||||||
|
|
||||||
Wed May 21 09:58:10 1997 Nick Clifton <nickc@cygnus.com>
|
Wed May 21 09:58:10 1997 Nick Clifton <nickc@cygnus.com>
|
||||||
|
|
||||||
* cofflink.c (mark_relocs): Add new function to mark symbols which
|
* cofflink.c (mark_relocs): Add new function to mark symbols which
|
||||||
are used by relocations. (_bfd_coff_link_input_bfd): Add call to
|
are used by relocations.
|
||||||
mark_relocs() and code to suppress the skipping of symbols that
|
(_bfd_coff_link_input_bfd): Add call to mark_relocs() and code to
|
||||||
have thus been marked.
|
suppress the skipping of symbols that have thus been marked.
|
||||||
|
|
||||||
Tue May 20 18:45:26 1997 Ian Lance Taylor <ian@cygnus.com>
|
Tue May 20 18:45:26 1997 Ian Lance Taylor <ian@cygnus.com>
|
||||||
|
|
||||||
|
@ -76,11 +81,11 @@ Fri May 9 10:15:27 1997 Nick Clifton <nickc@cygnus.com>
|
||||||
(global): Macro redefinitions set up to use these new functions.
|
(global): Macro redefinitions set up to use these new functions.
|
||||||
|
|
||||||
* coffcode.h (coff_mkobject_hook): Added call to
|
* coffcode.h (coff_mkobject_hook): Added call to
|
||||||
coff_arm_bfd_set_private_flags(). (coff_set_arch_mach_hook):
|
coff_arm_bfd_set_private_flags().
|
||||||
Added code to set machine type based on bits stored in internal
|
(coff_set_arch_mach_hook): Added code to set machine type based on
|
||||||
flags. (coff_set_flags): Added code to set the new bits in the
|
bits stored in internal flags.
|
||||||
flags field based on the machine number.
|
(coff_set_flags): Added code to set the new bits in the flags
|
||||||
|
field based on the machine number.
|
||||||
(function definition macros): Made all function definition macros
|
(function definition macros): Made all function definition macros
|
||||||
conditional so that they can be overridden by target specific
|
conditional so that they can be overridden by target specific
|
||||||
files.
|
files.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Support for the generic parts of most COFF variants, for BFD.
|
/* Support for the generic parts of most COFF variants, for BFD.
|
||||||
Copyright 1995, 1996 Free Software Foundation, Inc.
|
Copyright 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||||
Written by Cygnus Support.
|
Written by Cygnus Support.
|
||||||
|
|
||||||
This file is part of BFD, the Binary File Descriptor library.
|
This file is part of BFD, the Binary File Descriptor library.
|
||||||
|
@ -193,7 +193,31 @@ Most of this hacked by Steve Chamberlain,
|
||||||
#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
|
#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void coff_swap_reloc_in PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static unsigned int coff_swap_reloc_out PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static void coff_swap_filehdr_in PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static unsigned int coff_swap_filehdr_out PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static void coff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static unsigned int coff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static void coff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||||
|
static unsigned int coff_swap_aux_out
|
||||||
|
PARAMS ((bfd *, PTR, int, int, int, int, PTR));
|
||||||
|
static void coff_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static unsigned int coff_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static void add_data_entry
|
||||||
|
PARAMS ((bfd *, struct internal_extra_pe_aouthdr *, int, char *, bfd_vma));
|
||||||
|
static unsigned int coff_swap_aouthdr_out PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static void coff_swap_scnhdr_in PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static unsigned int coff_swap_scnhdr_out PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static boolean pe_print_idata PARAMS ((bfd *, PTR));
|
||||||
|
static boolean pe_print_edata PARAMS ((bfd *, PTR));
|
||||||
|
static boolean pe_print_pdata PARAMS ((bfd *, PTR));
|
||||||
|
static boolean pe_print_reloc PARAMS ((bfd *, PTR));
|
||||||
|
static boolean pe_print_private_bfd_data PARAMS ((bfd *, PTR));
|
||||||
|
static boolean pe_mkobject PARAMS ((bfd *));
|
||||||
|
static PTR pe_mkobject_hook PARAMS ((bfd *, PTR, PTR));
|
||||||
|
static boolean pe_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
|
@ -789,11 +813,30 @@ coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aouthdr_int->entry)
|
if (aouthdr_int->entry)
|
||||||
|
{
|
||||||
aouthdr_int->entry += a->ImageBase;
|
aouthdr_int->entry += a->ImageBase;
|
||||||
|
aouthdr_int->entry &= 0xffffffff;
|
||||||
|
}
|
||||||
if (aouthdr_int->tsize)
|
if (aouthdr_int->tsize)
|
||||||
|
{
|
||||||
aouthdr_int->text_start += a->ImageBase;
|
aouthdr_int->text_start += a->ImageBase;
|
||||||
|
aouthdr_int->text_start &= 0xffffffff;
|
||||||
|
}
|
||||||
if (aouthdr_int->dsize)
|
if (aouthdr_int->dsize)
|
||||||
|
{
|
||||||
aouthdr_int->data_start += a->ImageBase;
|
aouthdr_int->data_start += a->ImageBase;
|
||||||
|
aouthdr_int->data_start &= 0xffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef POWERPC_LE_PE
|
||||||
|
/* These three fields are normally set up by ppc_relocate_section.
|
||||||
|
In the case of reading a file in, we can pick them up from
|
||||||
|
the DataDirectory.
|
||||||
|
*/
|
||||||
|
first_thunk_address = a->DataDirectory[12].VirtualAddress ;
|
||||||
|
thunk_size = a->DataDirectory[12].Size;
|
||||||
|
import_table_size = a->DataDirectory[1].Size;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -809,7 +852,7 @@ static void add_data_entry (abfd, aout, idx, name, base)
|
||||||
/* add import directory information if it exists */
|
/* add import directory information if it exists */
|
||||||
if (sec != NULL)
|
if (sec != NULL)
|
||||||
{
|
{
|
||||||
aout->DataDirectory[idx].VirtualAddress = sec->vma - base;
|
aout->DataDirectory[idx].VirtualAddress = (sec->vma - base) & 0xffffffff;
|
||||||
aout->DataDirectory[idx].Size = pei_section_data (abfd, sec)->virt_size;
|
aout->DataDirectory[idx].Size = pei_section_data (abfd, sec)->virt_size;
|
||||||
sec->flags |= SEC_DATA;
|
sec->flags |= SEC_DATA;
|
||||||
}
|
}
|
||||||
|
@ -830,11 +873,20 @@ coff_swap_aouthdr_out (abfd, in, out)
|
||||||
bfd_vma ib = extra->ImageBase ;
|
bfd_vma ib = extra->ImageBase ;
|
||||||
|
|
||||||
if (aouthdr_in->tsize)
|
if (aouthdr_in->tsize)
|
||||||
|
{
|
||||||
aouthdr_in->text_start -= ib;
|
aouthdr_in->text_start -= ib;
|
||||||
|
aouthdr_in->text_start &= 0xffffffff;
|
||||||
|
}
|
||||||
if (aouthdr_in->dsize)
|
if (aouthdr_in->dsize)
|
||||||
|
{
|
||||||
aouthdr_in->data_start -= ib;
|
aouthdr_in->data_start -= ib;
|
||||||
|
aouthdr_in->data_start &= 0xffffffff;
|
||||||
|
}
|
||||||
if (aouthdr_in->entry)
|
if (aouthdr_in->entry)
|
||||||
|
{
|
||||||
aouthdr_in->entry -= ib;
|
aouthdr_in->entry -= ib;
|
||||||
|
aouthdr_in->entry &= 0xffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
#define FA(x) (((x) + fa -1 ) & (- fa))
|
#define FA(x) (((x) + fa -1 ) & (- fa))
|
||||||
#define SA(x) (((x) + sa -1 ) & (- sa))
|
#define SA(x) (((x) + sa -1 ) & (- sa))
|
||||||
|
@ -1007,6 +1059,7 @@ static void
|
||||||
if (scnhdr_int->s_vaddr != 0)
|
if (scnhdr_int->s_vaddr != 0)
|
||||||
{
|
{
|
||||||
scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase;
|
scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase;
|
||||||
|
scnhdr_int->s_vaddr &= 0xffffffff;
|
||||||
}
|
}
|
||||||
if (strcmp (scnhdr_int->s_name, _BSS) == 0)
|
if (strcmp (scnhdr_int->s_name, _BSS) == 0)
|
||||||
{
|
{
|
||||||
|
@ -1030,8 +1083,9 @@ coff_swap_scnhdr_out (abfd, in, out)
|
||||||
memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
|
memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
|
||||||
|
|
||||||
PUT_SCNHDR_VADDR (abfd,
|
PUT_SCNHDR_VADDR (abfd,
|
||||||
(scnhdr_int->s_vaddr
|
((scnhdr_int->s_vaddr
|
||||||
- pe_data(abfd)->pe_opthdr.ImageBase),
|
- pe_data(abfd)->pe_opthdr.ImageBase)
|
||||||
|
& 0xffffffff),
|
||||||
(bfd_byte *) scnhdr_ext->s_vaddr);
|
(bfd_byte *) scnhdr_ext->s_vaddr);
|
||||||
|
|
||||||
/* NT wants the size data to be rounded up to the next NT_FILE_ALIGNMENT
|
/* NT wants the size data to be rounded up to the next NT_FILE_ALIGNMENT
|
||||||
|
@ -1146,7 +1200,7 @@ coff_swap_scnhdr_out (abfd, in, out)
|
||||||
|
|
||||||
static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
|
static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
|
||||||
{
|
{
|
||||||
"Export Directory [.edata]",
|
"Export Directory [.edata (or where ever we found it)]",
|
||||||
"Import Directory [parts of .idata]",
|
"Import Directory [parts of .idata]",
|
||||||
"Resource Directory [.rsrc]",
|
"Resource Directory [.rsrc]",
|
||||||
"Exception Directory [.pdata]",
|
"Exception Directory [.pdata]",
|
||||||
|
@ -1168,9 +1222,9 @@ static char * dir_names[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] =
|
||||||
static boolean
|
static boolean
|
||||||
pe_print_idata(abfd, vfile)
|
pe_print_idata(abfd, vfile)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
void *vfile;
|
PTR vfile;
|
||||||
{
|
{
|
||||||
FILE *file = vfile;
|
FILE *file = (FILE *) vfile;
|
||||||
bfd_byte *data = 0;
|
bfd_byte *data = 0;
|
||||||
asection *section = bfd_get_section_by_name (abfd, ".idata");
|
asection *section = bfd_get_section_by_name (abfd, ".idata");
|
||||||
|
|
||||||
|
@ -1229,6 +1283,11 @@ pe_print_idata(abfd, vfile)
|
||||||
"\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n",
|
"\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n",
|
||||||
start_address, loadable_toc_address, toc_address);
|
start_address, loadable_toc_address, toc_address);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(file,
|
||||||
|
"\nNo reldata section! Function descriptor not decoded.\n");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
|
@ -1265,7 +1324,7 @@ pe_print_idata(abfd, vfile)
|
||||||
int idx;
|
int idx;
|
||||||
int j;
|
int j;
|
||||||
char *dll;
|
char *dll;
|
||||||
int adj = extra->ImageBase - section->vma;
|
int adj = (extra->ImageBase - section->vma) & 0xffffffff;
|
||||||
|
|
||||||
fprintf (file,
|
fprintf (file,
|
||||||
" %04lx\t",
|
" %04lx\t",
|
||||||
|
@ -1375,9 +1434,9 @@ pe_print_idata(abfd, vfile)
|
||||||
static boolean
|
static boolean
|
||||||
pe_print_edata (abfd, vfile)
|
pe_print_edata (abfd, vfile)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
void *vfile;
|
PTR vfile;
|
||||||
{
|
{
|
||||||
FILE *file = vfile;
|
FILE *file = (FILE *) vfile;
|
||||||
bfd_byte *data = 0;
|
bfd_byte *data = 0;
|
||||||
asection *section = bfd_get_section_by_name (abfd, ".edata");
|
asection *section = bfd_get_section_by_name (abfd, ".edata");
|
||||||
|
|
||||||
|
@ -1431,7 +1490,7 @@ pe_print_edata(abfd, vfile)
|
||||||
edt.npt_addr = bfd_get_32(abfd, data+32);
|
edt.npt_addr = bfd_get_32(abfd, data+32);
|
||||||
edt.ot_addr = bfd_get_32(abfd, data+36);
|
edt.ot_addr = bfd_get_32(abfd, data+36);
|
||||||
|
|
||||||
adj = extra->ImageBase - section->vma;
|
adj = (extra->ImageBase - section->vma) & 0xffffffff;
|
||||||
|
|
||||||
|
|
||||||
/* Dump the EDT first first */
|
/* Dump the EDT first first */
|
||||||
|
@ -1503,7 +1562,7 @@ pe_print_edata(abfd, vfile)
|
||||||
{
|
{
|
||||||
bfd_vma eat_member = bfd_get_32(abfd,
|
bfd_vma eat_member = bfd_get_32(abfd,
|
||||||
data + edt.eat_addr + (i*4) + adj);
|
data + edt.eat_addr + (i*4) + adj);
|
||||||
bfd_vma eat_actual = extra->ImageBase + eat_member;
|
bfd_vma eat_actual = (extra->ImageBase + eat_member) & 0xffffffff;
|
||||||
bfd_vma edata_start = bfd_get_section_vma(abfd,section);
|
bfd_vma edata_start = bfd_get_section_vma(abfd,section);
|
||||||
bfd_vma edata_end = edata_start + bfd_section_size (abfd, section);
|
bfd_vma edata_end = edata_start + bfd_section_size (abfd, section);
|
||||||
|
|
||||||
|
@ -1560,9 +1619,9 @@ pe_print_edata(abfd, vfile)
|
||||||
static boolean
|
static boolean
|
||||||
pe_print_pdata (abfd, vfile)
|
pe_print_pdata (abfd, vfile)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
void *vfile;
|
PTR vfile;
|
||||||
{
|
{
|
||||||
FILE *file = vfile;
|
FILE *file = (FILE *) vfile;
|
||||||
bfd_byte *data = 0;
|
bfd_byte *data = 0;
|
||||||
asection *section = bfd_get_section_by_name (abfd, ".pdata");
|
asection *section = bfd_get_section_by_name (abfd, ".pdata");
|
||||||
bfd_size_type datasize = 0;
|
bfd_size_type datasize = 0;
|
||||||
|
@ -1678,15 +1737,15 @@ static const char *tbl[6] =
|
||||||
"LOW",
|
"LOW",
|
||||||
"HIGHLOW",
|
"HIGHLOW",
|
||||||
"HIGHADJ",
|
"HIGHADJ",
|
||||||
"unknown"
|
"MIPS_JMPADDR"
|
||||||
};
|
};
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
pe_print_reloc (abfd, vfile)
|
pe_print_reloc (abfd, vfile)
|
||||||
bfd *abfd;
|
bfd *abfd;
|
||||||
void *vfile;
|
PTR vfile;
|
||||||
{
|
{
|
||||||
FILE *file = vfile;
|
FILE *file = (FILE *) vfile;
|
||||||
bfd_byte *data = 0;
|
bfd_byte *data = 0;
|
||||||
asection *section = bfd_get_section_by_name (abfd, ".reloc");
|
asection *section = bfd_get_section_by_name (abfd, ".reloc");
|
||||||
bfd_size_type datasize = 0;
|
bfd_size_type datasize = 0;
|
||||||
|
@ -1913,6 +1972,10 @@ pe_bfd_copy_private_section_data (ibfd, isec, obfd, osec)
|
||||||
bfd *obfd;
|
bfd *obfd;
|
||||||
asection *osec;
|
asection *osec;
|
||||||
{
|
{
|
||||||
|
if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour
|
||||||
|
|| bfd_get_flavour (obfd) != bfd_target_coff_flavour)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (coff_section_data (ibfd, isec) != NULL
|
if (coff_section_data (ibfd, isec) != NULL
|
||||||
&& pei_section_data (ibfd, isec) != NULL)
|
&& pei_section_data (ibfd, isec) != NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue