/* BFD back-end for PowerPC Microsoft Portable Executable files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
- 2012 Free Software Foundation, Inc.
+ Copyright (C) 1990-2015 Free Software Foundation, Inc.
Original version pieced together by Kim Knuttila (krk@cygnus.com)
static bfd_reloc_status_type ppc_refhi_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
-static bfd_reloc_status_type ppc_pair_reloc
+static bfd_reloc_status_type ppc_pair_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type ppc_toc16_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type ppc_section_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
-static bfd_reloc_status_type ppc_secrel_reloc
+static bfd_reloc_status_type ppc_secrel_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
static bfd_reloc_status_type ppc_imglue_reloc
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
get us started, so those I'll make sure work. Those marked FIXME are either
completely unverified or have a specific unknown marked in the comment. */
-/* Relocation entries for Windows/NT on PowerPC.
+/* Relocation entries for Windows/NT on PowerPC.
From the document "" we find the following listed as used relocs:
/* If we are performing a relocatable link, we don't need to do a
thing. The caller will take care of adjusting the reloc
addresses and symbol indices. */
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
return TRUE;
rel = relocs;
{
/* It is a file local symbol. */
int *local_toc_table;
- const char *name;
+ char name[SYMNMLEN + 1];
sym = syms + symndx;
- name = sym->_n._n_name;
+ strncpy (name, sym->_n._n_name, SYMNMLEN);
+ name[SYMNMLEN] = '\0';
local_toc_table = obj_coff_local_toc_table(input_bfd);
our_toc_offset = local_toc_table[symndx];
{
/* To solve this, we need to know whether or not the symbol
appearing on the call instruction is a glue function or not.
- A glue function must announce itself via a IMGLUE reloc, and
+ A glue function must announce itself via a IMGLUE reloc, and
the reloc contains the required toc restore instruction. */
DUMP_RELOC2 (howto->name, rel);
case IMAGE_REL_PPC_ABSOLUTE:
{
const char *my_name;
+ char buf[SYMNMLEN + 1];
if (h == 0)
- my_name = (syms+symndx)->_n._n_name;
+ {
+ strncpy (buf, (syms+symndx)->_n._n_name, SYMNMLEN);
+ buf[SYMNMLEN] = '\0';
+ my_name = buf;
+ }
else
my_name = h->root.root.root.string;
}
if (h == 0)
- {
- /* It is a file local symbol. */
- sym = syms + symndx;
- name = sym->_n._n_name;
- }
+ /* It is a file local symbol. */
+ sym = syms + symndx;
else
{
char *target = 0;
|| info->strip == strip_some)
o->lineno_count += sec->lineno_count;
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
o->reloc_count += sec->reloc_count;
if (sec->rawsize > max_contents_size)
if (sec->reloc_count > max_reloc_count)
max_reloc_count = sec->reloc_count;
}
- else if (info->relocatable
+ else if (bfd_link_relocatable (info)
&& (p->type == bfd_section_reloc_link_order
|| p->type == bfd_symbol_reloc_link_order))
++o->reloc_count;
/* If doing a relocatable link, allocate space for the pointers we
need to keep. */
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
{
unsigned int i;
memory until the end of the link. This wastes memory,
but only when doing a relocatable link, which is not the
common case. */
- BFD_ASSERT (info->relocatable);
+ BFD_ASSERT (bfd_link_relocatable (info));
amt = o->reloc_count;
amt *= sizeof (struct internal_reloc);
flaginfo.section_info[o->target_index].relocs =
the opportunity to clear the output_has_begun fields of all the
input BFD's. */
max_sym_count = 0;
- for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link.next)
{
bfd_size_type sz;
flaginfo.linenos = (bfd_byte *) bfd_malloc (amt);
flaginfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
flaginfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
- if (! info->relocatable)
+ if (! bfd_link_relocatable (info))
{
amt = max_reloc_count * sizeof (struct internal_reloc);
flaginfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
|| (flaginfo.linenos == NULL && max_lineno_count > 0)
|| (flaginfo.contents == NULL && max_contents_size > 0)
|| (flaginfo.external_relocs == NULL && max_reloc_count > 0)
- || (! info->relocatable
+ || (! bfd_link_relocatable (info)
&& flaginfo.internal_relocs == NULL
&& max_reloc_count > 0))
goto error_return;
flaginfo.outsyms = NULL;
}
- if (info->relocatable)
+ if (bfd_link_relocatable (info))
{
/* Now that we have written out all the global symbols, we know
the symbol indices to use for relocs against them, and we can
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
#ifndef COFF_WITH_PE
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+ | SEC_RELOC), /* section flags */
#else
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
- | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+ | SEC_RELOC | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
#endif
0, /* leading char */
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
#ifndef COFF_WITH_PE
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+ | SEC_RELOC), /* section flags */
#else
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
- | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+ | SEC_RELOC | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
#endif
0, /* leading char */