mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-24 12:39:59 +00:00
* targets.c (bfd_target): Remove unused align_power_min field.
* bfd-in2.h: Rebuild. * All backends: Remove initialization of align_power_min.
This commit is contained in:
parent
500d7394cf
commit
a56552441f
@ -1,7 +1,12 @@
|
||||
Tue Sep 19 17:02:26 1995 Ian Lance Taylor <ian@cygnus.com>
|
||||
|
||||
* targets.c (bfd_target): Remove unused align_power_min field.
|
||||
* bfd-in2.h: Rebuild.
|
||||
* All backends: Remove initialization of align_power_min.
|
||||
|
||||
Tue Sep 19 14:02:21 1995 steve chamberlain <sac@slash.cygnus.com>
|
||||
|
||||
* peicode.h (coff_swap_scnhdr_out): Get sizes for BSS right.
|
||||
(pr 8045)
|
||||
|
||||
Mon Sep 18 14:35:01 1995 Arne H. Juul <arnej@pvv.unit.no>
|
||||
|
||||
|
@ -502,7 +502,6 @@ const bfd_target a_out_adobe_vec =
|
||||
'_', /* symbol leading char */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
2, /* minumum alignment power */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
|
@ -2120,7 +2120,6 @@ typedef struct bfd_target
|
||||
char symbol_leading_char;
|
||||
char ar_pad_char;
|
||||
unsigned short ar_max_namelen;
|
||||
unsigned int align_power_min;
|
||||
bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
|
||||
bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
|
||||
void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
|
||||
|
256
bfd/binary.c
256
bfd/binary.c
@ -16,7 +16,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This is a BFD backend which may be used to write binary objects.
|
||||
It may only be used for output, not input. The intention is that
|
||||
@ -31,14 +31,28 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
the file. objcopy cooperates by specially setting the start
|
||||
address to zero by default. */
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
/* Any bfd we create by reading a binary file has three symbols:
|
||||
a start symbol, an end symbol, and an absolute length symbol. */
|
||||
#define BIN_SYMS 3
|
||||
|
||||
static boolean binary_mkobject PARAMS ((bfd *));
|
||||
static const bfd_target *binary_object_p PARAMS ((bfd *));
|
||||
static boolean binary_get_section_contents
|
||||
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
|
||||
static long binary_get_symtab_upper_bound PARAMS ((bfd *));
|
||||
static char *mangle_name PARAMS ((bfd *, char *));
|
||||
static long binary_get_symtab PARAMS ((bfd *, asymbol **));
|
||||
static asymbol *binary_make_empty_symbol PARAMS ((bfd *));
|
||||
static void binary_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
|
||||
static boolean binary_set_section_contents
|
||||
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
|
||||
static int binary_sizeof_headers PARAMS ((bfd *, boolean));
|
||||
|
||||
/* Create a binary object. Invoked via bfd_set_format. */
|
||||
|
||||
@ -49,17 +63,157 @@ binary_mkobject (abfd)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Most of the symbol routines can just return an error. */
|
||||
#define binary_get_symtab_upper_bound _bfd_nosymbols_get_symtab_upper_bound
|
||||
#define binary_get_symtab _bfd_nosymbols_get_symtab
|
||||
#define binary_print_symbol _bfd_nosymbols_print_symbol
|
||||
#define binary_get_symbol_info _bfd_nosymbols_get_symbol_info
|
||||
#define binary_bfd_is_local_label _bfd_nosymbols_bfd_is_local_label
|
||||
#define binary_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
/* Any file may be considered to be a binary file, provided the target
|
||||
was not defaulted. That is, it must be explicitly specified as
|
||||
being binary. */
|
||||
|
||||
/* We do have to provide a routine to make an empty symbol. */
|
||||
static const bfd_target *
|
||||
binary_object_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
struct stat statbuf;
|
||||
asection *sec;
|
||||
|
||||
if (abfd->target_defaulted)
|
||||
{
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
abfd->symcount = BIN_SYMS;
|
||||
|
||||
/* Find the file size. */
|
||||
if (bfd_stat (abfd, &statbuf) < 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* One data section. */
|
||||
sec = bfd_make_section (abfd, ".data");
|
||||
if (sec == NULL)
|
||||
return NULL;
|
||||
sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
|
||||
sec->vma = 0;
|
||||
sec->_raw_size = statbuf.st_size;
|
||||
sec->filepos = 0;
|
||||
|
||||
abfd->tdata.any = (PTR) sec;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
#define binary_close_and_cleanup _bfd_generic_close_and_cleanup
|
||||
#define binary_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
|
||||
#define binary_new_section_hook _bfd_generic_new_section_hook
|
||||
|
||||
/* Get contents of the only section. */
|
||||
|
||||
static boolean
|
||||
binary_get_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
asection *section;
|
||||
PTR location;
|
||||
file_ptr offset;
|
||||
bfd_size_type count;
|
||||
{
|
||||
if (bfd_seek (abfd, offset, SEEK_SET) != 0
|
||||
|| bfd_read (location, 1, count, abfd) != count)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Return the amount of memory needed to read the symbol table. */
|
||||
|
||||
static long
|
||||
binary_get_symtab_upper_bound (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
return (BIN_SYMS + 1) * sizeof (asymbol *);
|
||||
}
|
||||
|
||||
/* Create a symbol name based on the bfd's filename. */
|
||||
|
||||
static char *
|
||||
mangle_name (abfd, suffix)
|
||||
bfd *abfd;
|
||||
char *suffix;
|
||||
{
|
||||
int size;
|
||||
char *buf;
|
||||
char *p;
|
||||
|
||||
size = (strlen (bfd_get_filename (abfd))
|
||||
+ strlen (suffix)
|
||||
+ sizeof "_binary__");
|
||||
|
||||
buf = (char *) bfd_alloc (abfd, size);
|
||||
if (buf == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
|
||||
sprintf (buf, "_binary_%s_%s", bfd_get_filename (abfd), suffix);
|
||||
|
||||
/* Change any non-alphanumeric characters to underscores. */
|
||||
for (p = buf; *p; p++)
|
||||
if (! isalnum (*p))
|
||||
*p = '_';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Return the symbol table. */
|
||||
|
||||
static long
|
||||
binary_get_symtab (abfd, alocation)
|
||||
bfd *abfd;
|
||||
asymbol **alocation;
|
||||
{
|
||||
asection *sec = (asection *) abfd->tdata.any;
|
||||
asymbol *syms;
|
||||
unsigned int i;
|
||||
|
||||
syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
|
||||
if (syms == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Start symbol. */
|
||||
syms[0].the_bfd = abfd;
|
||||
syms[0].name = mangle_name (abfd, "start");
|
||||
syms[0].value = 0;
|
||||
syms[0].flags = BSF_GLOBAL;
|
||||
syms[0].section = sec;
|
||||
syms[0].udata.p = NULL;
|
||||
|
||||
/* End symbol. */
|
||||
syms[1].the_bfd = abfd;
|
||||
syms[1].name = mangle_name (abfd, "end");
|
||||
syms[1].value = sec->_raw_size;
|
||||
syms[1].flags = BSF_GLOBAL;
|
||||
syms[1].section = sec;
|
||||
syms[1].udata.p = NULL;
|
||||
|
||||
/* Size symbol. */
|
||||
syms[2].the_bfd = abfd;
|
||||
syms[2].name = mangle_name (abfd, "size");
|
||||
syms[2].value = sec->_raw_size;
|
||||
syms[2].flags = BSF_GLOBAL;
|
||||
syms[2].section = bfd_abs_section_ptr;
|
||||
syms[2].udata.p = NULL;
|
||||
|
||||
for (i = 0; i < BIN_SYMS; i++)
|
||||
*alocation++ = syms++;
|
||||
*alocation = NULL;
|
||||
|
||||
return BIN_SYMS;
|
||||
}
|
||||
|
||||
/* Make an empty symbol. */
|
||||
|
||||
static asymbol *
|
||||
binary_make_empty_symbol (abfd)
|
||||
@ -73,6 +227,32 @@ binary_make_empty_symbol (abfd)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define binary_print_symbol _bfd_nosymbols_print_symbol
|
||||
|
||||
/* Get information about a symbol. */
|
||||
|
||||
static void
|
||||
binary_get_symbol_info (ignore_abfd, symbol, ret)
|
||||
bfd *ignore_abfd;
|
||||
asymbol *symbol;
|
||||
symbol_info *ret;
|
||||
{
|
||||
bfd_symbol_info (symbol, ret);
|
||||
}
|
||||
|
||||
#define binary_bfd_is_local_label bfd_generic_is_local_label
|
||||
#define binary_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define binary_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define binary_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
#define binary_read_minisymbols _bfd_generic_read_minisymbols
|
||||
#define binary_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
|
||||
|
||||
#define binary_get_reloc_upper_bound \
|
||||
((long (*) PARAMS ((bfd *, asection *))) bfd_0l)
|
||||
#define binary_canonicalize_reloc \
|
||||
((long (*) PARAMS ((bfd *, asection *, arelent **, asymbol **))) bfd_0l)
|
||||
#define binary_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
|
||||
|
||||
/* Set the architecture of a binary file. */
|
||||
#define binary_set_arch_mach _bfd_generic_set_arch_mach
|
||||
|
||||
@ -86,25 +266,46 @@ binary_set_section_contents (abfd, sec, data, offset, size)
|
||||
file_ptr offset;
|
||||
bfd_size_type size;
|
||||
{
|
||||
/* In a binary file, the file position of a section is just the VMA
|
||||
minus the start address. */
|
||||
sec->filepos = bfd_section_vma (abfd, sec) - bfd_get_start_address (abfd);
|
||||
|
||||
if (sec->filepos + offset < 0)
|
||||
if (! abfd->output_has_begun)
|
||||
{
|
||||
file_ptr adjust;
|
||||
bfd_vma low;
|
||||
asection *s;
|
||||
|
||||
adjust = - (sec->filepos + offset);
|
||||
if (size <= adjust)
|
||||
return true;
|
||||
size -= adjust;
|
||||
data = (PTR) ((bfd_byte *) data + adjust);
|
||||
offset += adjust;
|
||||
/* The lowest section VMA sets the virtual address of the start
|
||||
of the file. We use the set the file position of all the
|
||||
sections. */
|
||||
low = abfd->sections->vma;
|
||||
for (s = abfd->sections->next; s != NULL; s = s->next)
|
||||
if (s->vma < low)
|
||||
low = s->vma;
|
||||
|
||||
for (s = abfd->sections; s != NULL; s = s->next)
|
||||
s->filepos = s->vma - low;
|
||||
|
||||
abfd->output_has_begun = true;
|
||||
}
|
||||
|
||||
return _bfd_generic_set_section_contents (abfd, sec, data, offset, size);
|
||||
}
|
||||
|
||||
/* No space is required for header information. */
|
||||
|
||||
static int
|
||||
binary_sizeof_headers (abfd, exec)
|
||||
bfd *abfd;
|
||||
boolean exec;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define binary_bfd_get_relocated_section_contents \
|
||||
bfd_generic_get_relocated_section_contents
|
||||
#define binary_bfd_relax_section bfd_generic_relax_section
|
||||
#define binary_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define binary_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define binary_bfd_final_link _bfd_generic_final_link
|
||||
#define binary_bfd_link_split_section _bfd_generic_link_split_section
|
||||
|
||||
const bfd_target binary_vec =
|
||||
{
|
||||
"binary", /* name */
|
||||
@ -117,7 +318,6 @@ const bfd_target binary_vec =
|
||||
0, /* symbol_leading_char */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
1, /* align_power_min */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
@ -126,7 +326,7 @@ const bfd_target binary_vec =
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
|
||||
{ /* bfd_check_format */
|
||||
_bfd_dummy_target,
|
||||
_bfd_dummy_target,
|
||||
binary_object_p, /* bfd_check_format */
|
||||
_bfd_dummy_target,
|
||||
_bfd_dummy_target,
|
||||
},
|
||||
@ -143,14 +343,14 @@ const bfd_target binary_vec =
|
||||
bfd_false,
|
||||
},
|
||||
|
||||
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
|
||||
BFD_JUMP_TABLE_GENERIC (binary),
|
||||
BFD_JUMP_TABLE_COPY (_bfd_generic),
|
||||
BFD_JUMP_TABLE_CORE (_bfd_nocore),
|
||||
BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
|
||||
BFD_JUMP_TABLE_SYMBOLS (binary),
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_RELOCS (binary),
|
||||
BFD_JUMP_TABLE_WRITE (binary),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_LINK (binary),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
NULL
|
||||
|
@ -581,7 +581,6 @@ const bfd_target a29kcoff_big_vec =
|
||||
'_', /* leading underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
2, /* minimum section alignment */
|
||||
/* data */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
|
@ -17,7 +17,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -1166,7 +1166,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
|
||||
|
||||
/* Get the howto structure for a generic reloc type. */
|
||||
|
||||
static CONST struct reloc_howto_struct *
|
||||
static reloc_howto_type *
|
||||
alpha_bfd_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
@ -1230,7 +1230,7 @@ alpha_bfd_reloc_type_lookup (abfd, code)
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return (CONST struct reloc_howto_struct *) NULL;
|
||||
return (reloc_howto_type *) NULL;
|
||||
}
|
||||
|
||||
return &alpha_howto_table[alpha_type];
|
||||
@ -1253,7 +1253,8 @@ alpha_convert_external_reloc (output_bfd, info, input_bfd, ext_rel, h)
|
||||
|
||||
BFD_ASSERT (info->relocateable);
|
||||
|
||||
if (h->root.type == bfd_link_hash_defined)
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection *hsec;
|
||||
const char *name;
|
||||
@ -1636,7 +1637,8 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
|
||||
if (! info->relocateable)
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined)
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
addend = (h->root.u.def.value
|
||||
+ h->root.u.def.section->output_section->vma
|
||||
+ h->root.u.def.section->output_offset);
|
||||
@ -1656,6 +1658,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
else
|
||||
{
|
||||
if (h->root.type != bfd_link_hash_defined
|
||||
&& h->root.type != bfd_link_hash_defweak
|
||||
&& h->indx == -1)
|
||||
{
|
||||
/* This symbol is not being written out. Pass
|
||||
@ -1785,6 +1788,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
if (r_extern)
|
||||
{
|
||||
if (h->root.type != bfd_link_hash_defined
|
||||
&& h->root.type != bfd_link_hash_defweak
|
||||
&& h->indx == -1)
|
||||
{
|
||||
/* This symbol is not being written out. */
|
||||
@ -1833,7 +1837,8 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
if (r_extern)
|
||||
{
|
||||
/* This is a reloc against a symbol. */
|
||||
if (h->root.type == bfd_link_hash_defined)
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection *hsec;
|
||||
|
||||
@ -1953,7 +1958,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data =
|
||||
alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
|
||||
_bfd_ecoff_make_section_hook, _bfd_ecoff_set_alignment_hook,
|
||||
_bfd_ecoff_slurp_symbol_table,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||
},
|
||||
/* Supported architecture. */
|
||||
bfd_arch_alpha,
|
||||
@ -2042,12 +2047,10 @@ const bfd_target ecoffalpha_little_vec =
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect
|
||||
flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
4, /* minimum alignment power */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
|
@ -265,6 +265,7 @@ static reloc_howto_type aoutarm_std_reloc_howto[] =
|
||||
(cache_ptr)->howto = aoutarm_std_reloc_howto + (dst)->r_type;
|
||||
|
||||
#define coff_rtype_to_howto coff_arm_rtype_to_howto
|
||||
|
||||
static reloc_howto_type *
|
||||
coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
bfd *abfd;
|
||||
@ -280,9 +281,7 @@ coff_arm_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
|
||||
if (rel->r_type == 11)
|
||||
{
|
||||
/* Gross, where can I get this from ?? */
|
||||
struct bfd_link_info *link_info = coff_data(sec->output_section->owner)->link_info;
|
||||
*addendp -= link_info->pe_info->image_base.value;
|
||||
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
}
|
||||
return howto;
|
||||
|
||||
@ -409,6 +408,7 @@ arm_reloc_type_lookup(abfd,code)
|
||||
/* We use the special COFF backend linker. */
|
||||
#define coff_relocate_section _bfd_coff_generic_relocate_section
|
||||
|
||||
|
||||
#include "coffcode.h"
|
||||
|
||||
#ifdef TARGET_LITTLE_SYM
|
||||
@ -432,7 +432,6 @@ const bfd_target TARGET_LITTLE_SYM =
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
2, /* minimum alignment power */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
@ -483,7 +482,6 @@ const bfd_target TARGET_BIG_SYM =
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
2, /* minimum alignment power */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
|
@ -16,7 +16,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -612,7 +612,6 @@ const bfd_target h8300coff_vec =
|
||||
'_', /* leading char */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
1, /* minimum section alignment */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
|
@ -17,7 +17,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -28,6 +28,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
static reloc_howto_type r_imm8 =
|
||||
HOWTO (R_H8500_IMM8, 0, 1, 8, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff, false);
|
||||
@ -160,7 +162,7 @@ static void reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = &(bfd_abs_symbol);
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
|
||||
@ -324,7 +326,6 @@ const bfd_target h8500coff_vec =
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
1, /* minimum section alignment */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
|
@ -16,7 +16,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -43,6 +43,7 @@ static reloc_howto_type *coff_i386_rtype_to_howto
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
||||
/* The page size is a guess based on ELF. */
|
||||
|
||||
#define COFF_PAGE_SIZE 0x1000
|
||||
|
||||
/* For some reason when using i386 COFF the value stored in the .text
|
||||
@ -70,6 +71,7 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
if (output_bfd == (bfd *) NULL)
|
||||
return bfd_reloc_continue;
|
||||
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
{
|
||||
/* We are relocating a common symbol. The current value in the
|
||||
@ -94,44 +96,53 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
|
||||
diff = reloc_entry->addend;
|
||||
}
|
||||
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
if (reloc_entry->howto->type == 7)
|
||||
{
|
||||
/* diff -= coff_data(output_bfd)->link_info->pe_info.image_base.value;*/
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define DOIT(x) \
|
||||
x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
|
||||
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
if (diff != 0)
|
||||
{
|
||||
reloc_howto_type *howto = reloc_entry->howto;
|
||||
unsigned char *addr = (unsigned char *) data + reloc_entry->address;
|
||||
|
||||
switch (howto->size)
|
||||
{
|
||||
case 0:
|
||||
switch (howto->size)
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
{
|
||||
char x = bfd_get_8 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_8 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
short x = bfd_get_16 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_16 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
long x = bfd_get_32 (abfd, addr);
|
||||
DOIT (x);
|
||||
bfd_put_32 (abfd, x, addr);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Now let bfd_perform_relocation finish everything up. */
|
||||
return bfd_reloc_continue;
|
||||
@ -165,7 +176,7 @@ static reloc_howto_type howto_table[] =
|
||||
0xffffffff, /* dst_mask */
|
||||
true), /* pcrel_offset */
|
||||
/* {7}, */
|
||||
HOWTO (7, /* type */
|
||||
HOWTO (R_IMAGEBASE, /* type */
|
||||
0, /* rightshift */
|
||||
2, /* size (0 = byte, 1 = short, 2 = long) */
|
||||
32, /* bitsize */
|
||||
@ -173,7 +184,7 @@ static reloc_howto_type howto_table[] =
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
coff_i386_reloc, /* special_function */
|
||||
"dir32", /* name */
|
||||
"rva32", /* name */
|
||||
true, /* partial_inplace */
|
||||
0xffffffff, /* src_mask */
|
||||
0xffffffff, /* dst_mask */
|
||||
@ -353,12 +364,12 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
/* I think we *do* want to bypass this. If we don't, I have seen some data
|
||||
parameters get the wrong relcation address. If I link two versions
|
||||
with and without this section bypassed and then do a binary comparison,
|
||||
the addresses which are different can be looked up in the map. The
|
||||
case in which this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map */
|
||||
/* I think we *do* want to bypass this. If we don't, I have seen some data
|
||||
parameters get the wrong relcation address. If I link two versions
|
||||
with and without this section bypassed and then do a binary comparison,
|
||||
the addresses which are different can be looked up in the map. The
|
||||
case in which this section has been bypassed has addresses which correspond
|
||||
to values I can find in the map */
|
||||
*addendp -= sym->n_value;
|
||||
#endif
|
||||
}
|
||||
@ -372,7 +383,12 @@ coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
|
||||
|
||||
#ifdef COFF_WITH_PE
|
||||
if (howto->pc_relative)
|
||||
*addendp -= 4;
|
||||
*addendp -= 4;
|
||||
|
||||
if (rel->r_type == R_IMAGEBASE)
|
||||
{
|
||||
*addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
|
||||
}
|
||||
#endif
|
||||
|
||||
return howto;
|
||||
@ -418,7 +434,6 @@ const bfd_target
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
|
||||
2, /* minimum alignment power */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
|
270
bfd/coff-mips.c
270
bfd/coff-mips.c
@ -17,7 +17,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -104,6 +104,7 @@ static void mips_relocate_hi PARAMS ((struct internal_reloc *refhi,
|
||||
static boolean mips_relocate_section PARAMS ((bfd *, struct bfd_link_info *,
|
||||
bfd *, asection *,
|
||||
bfd_byte *, PTR));
|
||||
static boolean mips_read_relocs PARAMS ((bfd *, asection *));
|
||||
static boolean mips_relax_section PARAMS ((bfd *, asection *,
|
||||
struct bfd_link_info *,
|
||||
boolean *));
|
||||
@ -1065,7 +1066,7 @@ mips_switch_reloc (abfd,
|
||||
|
||||
/* Get the howto structure for a generic reloc type. */
|
||||
|
||||
static CONST struct reloc_howto_struct *
|
||||
static reloc_howto_type *
|
||||
mips_bfd_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
@ -1109,7 +1110,7 @@ mips_bfd_reloc_type_lookup (abfd, code)
|
||||
mips_type = MIPS_R_SWITCH;
|
||||
break;
|
||||
default:
|
||||
return (CONST struct reloc_howto_struct *) NULL;
|
||||
return (reloc_howto_type *) NULL;
|
||||
}
|
||||
|
||||
return &mips_howto_table[mips_type];
|
||||
@ -1372,16 +1373,17 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
addend = ecoff_data (input_bfd)->gp - gp;
|
||||
}
|
||||
else if (! info->relocateable
|
||||
|| h->root.type == bfd_link_hash_defined)
|
||||
|| h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
/* This is a relocation against an undefined or common
|
||||
symbol. The current addend in the instruction is
|
||||
simply the desired offset into the symbol (normally
|
||||
zero). We are going to change this into a relocation
|
||||
against a defined symbol, so we want the instruction
|
||||
to hold the difference between the final definition
|
||||
of the symbol (which will end up in RELOCATION) and
|
||||
the GP value of OUTPUT_BFD (which is in GP). */
|
||||
/* This is a relocation against a defined symbol. The
|
||||
current addend in the instruction is simply the
|
||||
desired offset into the symbol (normally zero). We
|
||||
are going to change this into a relocation against a
|
||||
defined symbol, so we want the instruction to hold
|
||||
the difference between the final definition of the
|
||||
symbol (which will end up in RELOCATION) and the GP
|
||||
value of OUTPUT_BFD (which is in GP). */
|
||||
addend = - gp;
|
||||
}
|
||||
else
|
||||
@ -1422,8 +1424,8 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
+ int_rel.r_vaddr
|
||||
- input_section->vma);
|
||||
memmove (here + PCREL16_EXPANSION_ADJUSTMENT, here,
|
||||
(input_section->_raw_size
|
||||
- (int_rel.r_vaddr - input_section->vma)));
|
||||
(size_t) (input_section->_raw_size
|
||||
- (int_rel.r_vaddr - input_section->vma)));
|
||||
|
||||
/* Generate the new instructions. */
|
||||
if (! mips_relax_pcrel16 (info, input_bfd, input_section,
|
||||
@ -1487,7 +1489,9 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
the existing reloc. */
|
||||
if (int_rel.r_extern)
|
||||
{
|
||||
if (h->root.type == bfd_link_hash_defined)
|
||||
if ((h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
&& ! bfd_is_abs_section (h->root.u.def.section))
|
||||
{
|
||||
const char *name;
|
||||
|
||||
@ -1676,7 +1680,8 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
if (int_rel.r_extern)
|
||||
{
|
||||
/* This is a reloc against a symbol. */
|
||||
if (h->root.type == bfd_link_hash_defined)
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
asection *hsec;
|
||||
|
||||
@ -1781,6 +1786,57 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Read in the relocs for a section. */
|
||||
|
||||
static boolean
|
||||
mips_read_relocs (abfd, sec)
|
||||
bfd *abfd;
|
||||
asection *sec;
|
||||
{
|
||||
struct ecoff_section_tdata *section_tdata;
|
||||
|
||||
section_tdata = ecoff_section_data (abfd, sec);
|
||||
if (section_tdata == (struct ecoff_section_tdata *) NULL)
|
||||
{
|
||||
sec->used_by_bfd =
|
||||
(PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata));
|
||||
if (sec->used_by_bfd == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
|
||||
section_tdata = ecoff_section_data (abfd, sec);
|
||||
section_tdata->external_relocs = NULL;
|
||||
section_tdata->contents = NULL;
|
||||
section_tdata->offsets = NULL;
|
||||
}
|
||||
|
||||
if (section_tdata->external_relocs == NULL)
|
||||
{
|
||||
bfd_size_type external_relocs_size;
|
||||
|
||||
external_relocs_size = (ecoff_backend (abfd)->external_reloc_size
|
||||
* sec->reloc_count);
|
||||
|
||||
section_tdata->external_relocs =
|
||||
(PTR) bfd_alloc (abfd, external_relocs_size);
|
||||
if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
|
||||
|| (bfd_read (section_tdata->external_relocs, 1,
|
||||
external_relocs_size, abfd)
|
||||
!= external_relocs_size))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Relax a section when linking a MIPS ECOFF file. This is used for
|
||||
embedded PIC code, which always uses PC relative branches which
|
||||
only have an 18 bit range on MIPS. If a branch is not in range, we
|
||||
@ -1838,40 +1894,16 @@ mips_relax_section (abfd, sec, info, again)
|
||||
|
||||
/* Read in the relocs, if we haven't already got them. */
|
||||
section_tdata = ecoff_section_data (abfd, sec);
|
||||
if (section_tdata == (struct ecoff_section_tdata *) NULL)
|
||||
if (section_tdata == (struct ecoff_section_tdata *) NULL
|
||||
|| section_tdata->external_relocs == NULL)
|
||||
{
|
||||
bfd_size_type external_reloc_size;
|
||||
bfd_size_type external_relocs_size;
|
||||
|
||||
sec->used_by_bfd =
|
||||
(PTR) bfd_alloc_by_size_t (abfd, sizeof (struct ecoff_section_tdata));
|
||||
if (sec->used_by_bfd == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
section_tdata = ecoff_section_data (abfd, sec);
|
||||
section_tdata->contents = NULL;
|
||||
section_tdata->offsets = NULL;
|
||||
|
||||
external_reloc_size = ecoff_backend (abfd)->external_reloc_size;
|
||||
external_relocs_size = external_reloc_size * sec->reloc_count;
|
||||
|
||||
section_tdata->external_relocs =
|
||||
(PTR) bfd_alloc (abfd, external_relocs_size);
|
||||
if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
goto error_return;
|
||||
}
|
||||
|
||||
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
|
||||
|| (bfd_read (section_tdata->external_relocs, 1,
|
||||
external_relocs_size, abfd)
|
||||
!= external_relocs_size))
|
||||
if (! mips_read_relocs (abfd, sec))
|
||||
goto error_return;
|
||||
section_tdata = ecoff_section_data (abfd, sec);
|
||||
}
|
||||
|
||||
if (sec->_cooked_size == 0)
|
||||
{
|
||||
/* We must initialize _cooked_size only the first time we are
|
||||
called. */
|
||||
sec->_cooked_size = sec->_raw_size;
|
||||
@ -1927,7 +1959,8 @@ mips_relax_section (abfd, sec, info, again)
|
||||
if (h == (struct ecoff_link_hash_entry *) NULL)
|
||||
abort ();
|
||||
|
||||
if (h->root.type != bfd_link_hash_defined)
|
||||
if (h->root.type != bfd_link_hash_defined
|
||||
&& h->root.type != bfd_link_hash_defweak)
|
||||
{
|
||||
/* Just ignore undefined symbols. These will presumably
|
||||
generate an error later in the link. */
|
||||
@ -1972,7 +2005,7 @@ mips_relax_section (abfd, sec, info, again)
|
||||
if (info->keep_memory)
|
||||
contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size);
|
||||
else
|
||||
contents = (bfd_byte *) malloc (sec->_raw_size);
|
||||
contents = (bfd_byte *) malloc ((size_t) sec->_raw_size);
|
||||
if (contents == (bfd_byte *) NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
@ -2180,7 +2213,8 @@ mips_relax_section (abfd, sec, info, again)
|
||||
|
||||
adj_h = *adj_h_ptr;
|
||||
if (adj_h != (struct ecoff_link_hash_entry *) NULL
|
||||
&& adj_h->root.type == bfd_link_hash_defined
|
||||
&& (adj_h->root.type == bfd_link_hash_defined
|
||||
|| adj_h->root.type == bfd_link_hash_defweak)
|
||||
&& adj_h->root.u.def.section == sec
|
||||
&& adj_h->esym.asym.value > int_rel.r_vaddr)
|
||||
adj_h->root.u.def.value += PCREL16_EXPANSION_ADJUSTMENT;
|
||||
@ -2258,6 +2292,133 @@ mips_relax_pcrel16 (info, input_bfd, input_section, h, location, address)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Given a .sdata section and a .rel.sdata in-memory section, store
|
||||
relocation information into the .rel.sdata section which can be
|
||||
used at runtime to relocate the section. This is called by the
|
||||
linker when the --embedded-relocs switch is used. This is called
|
||||
after the add_symbols entry point has been called for all the
|
||||
objects, and before the final_link entry point is called. This
|
||||
function presumes that the object was compiled using
|
||||
-membedded-pic. */
|
||||
|
||||
boolean
|
||||
bfd_mips_ecoff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
asection *datasec;
|
||||
asection *relsec;
|
||||
char **errmsg;
|
||||
{
|
||||
struct ecoff_link_hash_entry **sym_hashes;
|
||||
struct ecoff_section_tdata *section_tdata;
|
||||
struct external_reloc *ext_rel;
|
||||
struct external_reloc *ext_rel_end;
|
||||
bfd_byte *p;
|
||||
|
||||
BFD_ASSERT (! info->relocateable);
|
||||
|
||||
*errmsg = NULL;
|
||||
|
||||
if (datasec->reloc_count == 0)
|
||||
return true;
|
||||
|
||||
sym_hashes = ecoff_data (abfd)->sym_hashes;
|
||||
|
||||
if (! mips_read_relocs (abfd, datasec))
|
||||
return false;
|
||||
|
||||
relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 4);
|
||||
if (relsec->contents == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
|
||||
p = relsec->contents;
|
||||
|
||||
section_tdata = ecoff_section_data (abfd, datasec);
|
||||
ext_rel = (struct external_reloc *) section_tdata->external_relocs;
|
||||
ext_rel_end = ext_rel + datasec->reloc_count;
|
||||
for (; ext_rel < ext_rel_end; ext_rel++, p += 4)
|
||||
{
|
||||
struct internal_reloc int_rel;
|
||||
boolean text_relative;
|
||||
|
||||
mips_ecoff_swap_reloc_in (abfd, (PTR) ext_rel, &int_rel);
|
||||
|
||||
/* We are going to write a four byte word into the runtime reloc
|
||||
section. The word will be the address in the data section
|
||||
which must be relocated. This must be on a word boundary,
|
||||
which means the lower two bits must be zero. We use the
|
||||
least significant bit to indicate how the value in the data
|
||||
section must be relocated. A 0 means that the value is
|
||||
relative to the text section, while a 1 indicates that the
|
||||
value is relative to the data section. Given that we are
|
||||
assuming the code was compiled using -membedded-pic, there
|
||||
should not be any other possibilities. */
|
||||
|
||||
/* We can only relocate REFWORD relocs at run time. */
|
||||
if (int_rel.r_type != MIPS_R_REFWORD)
|
||||
{
|
||||
*errmsg = "unsupported reloc type";
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (int_rel.r_extern)
|
||||
{
|
||||
struct ecoff_link_hash_entry *h;
|
||||
|
||||
h = sym_hashes[int_rel.r_symndx];
|
||||
/* If h is NULL, that means that there is a reloc against an
|
||||
external symbol which we thought was just a debugging
|
||||
symbol. This should not happen. */
|
||||
if (h == (struct ecoff_link_hash_entry *) NULL)
|
||||
abort ();
|
||||
if ((h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
&& (h->root.u.def.section->flags & SEC_CODE) != 0)
|
||||
text_relative = true;
|
||||
else
|
||||
text_relative = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (int_rel.r_symndx)
|
||||
{
|
||||
case RELOC_SECTION_TEXT:
|
||||
text_relative = true;
|
||||
break;
|
||||
case RELOC_SECTION_SDATA:
|
||||
case RELOC_SECTION_SBSS:
|
||||
case RELOC_SECTION_LIT8:
|
||||
text_relative = false;
|
||||
break;
|
||||
default:
|
||||
/* No other sections should appear in -membedded-pic
|
||||
code. */
|
||||
*errmsg = "reloc against unsupported section";
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((int_rel.r_offset & 3) != 0)
|
||||
{
|
||||
*errmsg = "reloc not properly aligned";
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
}
|
||||
|
||||
bfd_put_32 (abfd,
|
||||
(int_rel.r_vaddr - datasec->vma + datasec->output_offset
|
||||
+ (text_relative ? 0 : 1)),
|
||||
p);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* This is the ECOFF backend structure. The backend field of the
|
||||
target vector points to this. */
|
||||
@ -2282,7 +2443,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
|
||||
_bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
|
||||
_bfd_ecoff_make_section_hook, _bfd_ecoff_set_alignment_hook,
|
||||
_bfd_ecoff_slurp_symbol_table,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
||||
},
|
||||
/* Supported architecture. */
|
||||
bfd_arch_mips,
|
||||
@ -2371,12 +2532,10 @@ const bfd_target ecoff_little_vec =
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect
|
||||
flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
4, /* minimum alignment power */
|
||||
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
||||
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
||||
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
||||
@ -2415,11 +2574,10 @@ const bfd_target ecoff_big_vec =
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect flags */
|
||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA),
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
4, /* minimum alignment power */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16,
|
||||
|
@ -768,7 +768,6 @@ const bfd_target rs6000coff_vec =
|
||||
0, /* leading char */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen??? FIXMEmgo */
|
||||
3, /* default alignment power */
|
||||
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
|
@ -17,7 +17,7 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -28,6 +28,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#include "coff/internal.h"
|
||||
#include "libcoff.h"
|
||||
|
||||
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
|
||||
|
||||
static reloc_howto_type r_imm32 =
|
||||
HOWTO (R_IMM32, 0, 1, 32, false, 0,
|
||||
complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,
|
||||
@ -136,7 +138,7 @@ reloc_processing (relent, reloc, symbols, abfd, section)
|
||||
}
|
||||
else
|
||||
{
|
||||
relent->sym_ptr_ptr = &(bfd_abs_symbol);
|
||||
relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
|
||||
}
|
||||
|
||||
|
||||
@ -250,7 +252,6 @@ const bfd_target z8kcoff_vec =
|
||||
'_', /* leading symbol underscore */
|
||||
'/', /* ar_pad_char */
|
||||
15, /* ar_max_namelen */
|
||||
1, /* minimum section alignment */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
|
@ -3395,7 +3395,6 @@ const bfd_target ieee_vec =
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
1, /* minimum alignment */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* BFD back-end for OSF/1 core files.
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
@ -15,13 +15,10 @@ GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
/* This file can only be compiled on systems which use OSF/1 style
|
||||
core files. In the config/XXXXXX.mh file for such a system add
|
||||
HDEFINES=-DOSF_CORE
|
||||
HDEPFILES=osf-core.o
|
||||
*/
|
||||
core files. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -39,7 +36,7 @@ make_bfd_asection PARAMS ((bfd *, CONST char *, flagword, bfd_size_type,
|
||||
bfd_vma, file_ptr));
|
||||
static asymbol *
|
||||
osf_core_make_empty_symbol PARAMS ((bfd *));
|
||||
static bfd_target *
|
||||
static const bfd_target *
|
||||
osf_core_core_file_p PARAMS ((bfd *));
|
||||
static char *
|
||||
osf_core_core_file_failing_command PARAMS ((bfd *));
|
||||
@ -73,7 +70,7 @@ make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
|
||||
{
|
||||
asection *asect;
|
||||
|
||||
asect = bfd_make_section (abfd, name);
|
||||
asect = bfd_make_section_anyway (abfd, name);
|
||||
if (!asect)
|
||||
return NULL;
|
||||
|
||||
@ -96,7 +93,7 @@ osf_core_make_empty_symbol (abfd)
|
||||
return new;
|
||||
}
|
||||
|
||||
static bfd_target *
|
||||
static const bfd_target *
|
||||
osf_core_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
@ -104,7 +101,6 @@ osf_core_core_file_p (abfd)
|
||||
int i;
|
||||
char *secname;
|
||||
struct core_filehdr core_header;
|
||||
int dseccnt = 0;
|
||||
|
||||
val = bfd_read ((PTR)&core_header, 1, sizeof core_header, abfd);
|
||||
if (val != sizeof core_header)
|
||||
@ -124,6 +120,7 @@ osf_core_core_file_p (abfd)
|
||||
for (i = 0; i < core_header.nscns; i++)
|
||||
{
|
||||
struct core_scnhdr core_scnhdr;
|
||||
flagword flags;
|
||||
|
||||
val = bfd_read ((PTR)&core_scnhdr, 1, sizeof core_scnhdr, abfd);
|
||||
if (val != sizeof core_scnhdr)
|
||||
@ -136,22 +133,16 @@ osf_core_core_file_p (abfd)
|
||||
switch (core_scnhdr.scntype)
|
||||
{
|
||||
case SCNRGN:
|
||||
/* OSF/1 has multiple data sections (data, bss and data/bss sections
|
||||
for shared libraries), but bfd doesn't permit data sections with
|
||||
the same name. Construct a unique section name. */
|
||||
secname = bfd_alloc (abfd, 40);
|
||||
if (!secname)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
sprintf (secname, ".data%d", dseccnt++);
|
||||
secname = ".data";
|
||||
flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
break;
|
||||
case SCNSTACK:
|
||||
secname = ".stack";
|
||||
flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
|
||||
break;
|
||||
case SCNREGS:
|
||||
secname = ".reg";
|
||||
flags = SEC_HAS_CONTENTS;
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "Unhandled OSF/1 core file section type %d\n",
|
||||
@ -159,8 +150,7 @@ osf_core_core_file_p (abfd)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!make_bfd_asection (abfd, secname,
|
||||
SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
|
||||
if (!make_bfd_asection (abfd, secname, flags,
|
||||
(bfd_size_type) core_scnhdr.size,
|
||||
(bfd_vma) core_scnhdr.vaddr,
|
||||
(file_ptr) core_scnhdr.scnptr))
|
||||
@ -203,6 +193,8 @@ osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
#define osf_core_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define osf_core_find_nearest_line _bfd_nosymbols_find_nearest_line
|
||||
#define osf_core_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
#define osf_core_read_minisymbols _bfd_nosymbols_read_minisymbols
|
||||
#define osf_core_minisymbol_to_symbol _bfd_nosymbols_minisymbol_to_symbol
|
||||
|
||||
/* If somebody calls any byte-swapping routines, shoot them. */
|
||||
static void
|
||||
@ -215,7 +207,7 @@ swap_abort()
|
||||
#define NO_SIGNED_GET \
|
||||
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
|
||||
|
||||
bfd_target osf_core_vec =
|
||||
const bfd_target osf_core_vec =
|
||||
{
|
||||
"osf-core",
|
||||
bfd_target_unknown_flavour,
|
||||
@ -228,7 +220,6 @@ bfd_target osf_core_vec =
|
||||
0, /* symbol prefix */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
3, /* minimum alignment power */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 64 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 32 bit data */
|
||||
NO_GET, NO_SIGNED_GET, NO_PUT, /* 16 bit data */
|
||||
@ -259,6 +250,7 @@ bfd_target osf_core_vec =
|
||||
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
|
||||
BFD_JUMP_TABLE_WRITE (_bfd_generic),
|
||||
BFD_JUMP_TABLE_LINK (_bfd_nolink),
|
||||
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
|
||||
|
||||
(PTR) 0 /* backend_data */
|
||||
};
|
||||
|
@ -2618,6 +2618,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
|
||||
case R_RSEL:
|
||||
case R_COMP1:
|
||||
case R_COMP2:
|
||||
case R_BEGIN_BRTAB:
|
||||
case R_END_BRTAB:
|
||||
reloc_offset = bfd_reloc->address;
|
||||
break;
|
||||
|
||||
@ -2747,6 +2749,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep)
|
||||
case R_FSEL:
|
||||
case R_LSEL:
|
||||
case R_RSEL:
|
||||
case R_BEGIN_BRTAB:
|
||||
case R_END_BRTAB:
|
||||
bfd_put_8 (abfd, bfd_reloc->howto->type, p);
|
||||
subspace_reloc_size += 1;
|
||||
p += 1;
|
||||
@ -5952,6 +5956,7 @@ som_bfd_link_split_section (abfd, sec)
|
||||
#define som_truncate_arname bfd_bsd_truncate_arname
|
||||
#define som_slurp_extended_name_table _bfd_slurp_extended_name_table
|
||||
#define som_update_armap_timestamp bfd_true
|
||||
#define som_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
|
||||
|
||||
#define som_get_lineno _bfd_nosymbols_get_lineno
|
||||
#define som_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
||||
@ -5982,7 +5987,6 @@ const bfd_target som_vec =
|
||||
0,
|
||||
'/', /* ar_pad_char */
|
||||
14, /* ar_max_namelen */
|
||||
3, /* minimum alignment */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
|
@ -1248,7 +1248,6 @@ const bfd_target srec_vec =
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
1, /* minimum alignment */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
@ -1304,7 +1303,6 @@ const bfd_target symbolsrec_vec =
|
||||
0, /* leading underscore */
|
||||
' ', /* ar_pad_char */
|
||||
16, /* ar_max_namelen */
|
||||
1, /* minimum alignment */
|
||||
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
||||
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
||||
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
|
||||
|
@ -197,10 +197,6 @@ The maximum number of characters in an archive header.
|
||||
|
||||
. unsigned short ar_max_namelen;
|
||||
|
||||
The minimum alignment restriction for any section.
|
||||
|
||||
. unsigned int align_power_min;
|
||||
|
||||
Entries for byte swapping for data. These are different from the other
|
||||
entry points, since they don't take a BFD asthe first argument.
|
||||
Certain other handlers could do the same.
|
||||
|
Loading…
Reference in New Issue
Block a user