/* PowerPC-specific support for 32-bit ELF
- Copyright (C) 1994-2015 Free Software Foundation, Inc.
+ Copyright (C) 1994-2016 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
#include "elf32-ppc.h"
#include "elf-vxworks.h"
#include "dwarf2.h"
-#include "elf-linux-psinfo.h"
typedef enum split16_format_type
{
char pr_psargs[80]; /* Initial part of arg list. */
};
-/* Helper macro to swap (properly handling endianess) things from the
- `elf_internal_prpsinfo' structure to the `elf_external_ppc_prpsinfo32'
- structure.
-
- Note that FROM should be a pointer, and TO should be the explicit type. */
-
-#define PPC_LINUX_PRPSINFO32_SWAP_FIELDS(abfd, from, to) \
- do \
- { \
- H_PUT_8 (abfd, from->pr_state, &to.pr_state); \
- H_PUT_8 (abfd, from->pr_sname, &to.pr_sname); \
- H_PUT_8 (abfd, from->pr_zomb, &to.pr_zomb); \
- H_PUT_8 (abfd, from->pr_nice, &to.pr_nice); \
- H_PUT_32 (abfd, from->pr_flag, to.pr_flag); \
- H_PUT_32 (abfd, from->pr_uid, to.pr_uid); \
- H_PUT_32 (abfd, from->pr_gid, to.pr_gid); \
- H_PUT_32 (abfd, from->pr_pid, to.pr_pid); \
- H_PUT_32 (abfd, from->pr_ppid, to.pr_ppid); \
- H_PUT_32 (abfd, from->pr_pgrp, to.pr_pgrp); \
- H_PUT_32 (abfd, from->pr_sid, to.pr_sid); \
- strncpy (to.pr_fname, from->pr_fname, sizeof (to.pr_fname)); \
- strncpy (to.pr_psargs, from->pr_psargs, sizeof (to.pr_psargs)); \
- } while (0)
+/* Helper function to copy an elf_internal_linux_prpsinfo in host
+ endian to an elf_external_ppc_linux_prpsinfo32 in target endian. */
+static inline void
+swap_ppc_linux_prpsinfo32_out (bfd *obfd,
+ const struct elf_internal_linux_prpsinfo *from,
+ struct elf_external_ppc_linux_prpsinfo32 *to)
+{
+ bfd_put_8 (obfd, from->pr_state, &to->pr_state);
+ bfd_put_8 (obfd, from->pr_sname, &to->pr_sname);
+ bfd_put_8 (obfd, from->pr_zomb, &to->pr_zomb);
+ bfd_put_8 (obfd, from->pr_nice, &to->pr_nice);
+ bfd_put_32 (obfd, from->pr_flag, to->pr_flag);
+ bfd_put_32 (obfd, from->pr_uid, to->pr_uid);
+ bfd_put_32 (obfd, from->pr_gid, to->pr_gid);
+ bfd_put_32 (obfd, from->pr_pid, to->pr_pid);
+ bfd_put_32 (obfd, from->pr_ppid, to->pr_ppid);
+ bfd_put_32 (obfd, from->pr_pgrp, to->pr_pgrp);
+ bfd_put_32 (obfd, from->pr_sid, to->pr_sid);
+ strncpy (to->pr_fname, from->pr_fname, sizeof (to->pr_fname));
+ strncpy (to->pr_psargs, from->pr_psargs, sizeof (to->pr_psargs));
+}
\f
/* Initialize the ppc_elf_howto_table, so that linear accesses can be done. */
}
char *
-elfcore_write_ppc_linux_prpsinfo32 (bfd *abfd, char *buf, int *bufsiz,
- const struct elf_internal_linux_prpsinfo *prpsinfo)
+elfcore_write_ppc_linux_prpsinfo32
+ (bfd *abfd,
+ char *buf,
+ int *bufsiz,
+ const struct elf_internal_linux_prpsinfo *prpsinfo)
{
struct elf_external_ppc_linux_prpsinfo32 data;
- memset (&data, 0, sizeof (data));
- PPC_LINUX_PRPSINFO32_SWAP_FIELDS (abfd, prpsinfo, data);
-
+ swap_ppc_linux_prpsinfo32_out (abfd, prpsinfo, &data);
return elfcore_write_note (abfd, buf, bufsiz,
"CORE", NT_PRPSINFO, &data, sizeof (data));
}
enum elf_ppc_reloc_type r_type;
struct elf_link_hash_entry *h;
int tls_type;
+ struct plt_entry **ifunc;
r_symndx = ELF32_R_SYM (rel->r_info);
if (r_symndx < symtab_hdr->sh_info)
tls_type = 0;
r_type = ELF32_R_TYPE (rel->r_info);
+ ifunc = NULL;
if (h == NULL && !htab->is_vxworks)
{
Elf_Internal_Sym *isym = bfd_sym_from_r_symndx (&htab->sym_cache,
if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
{
- struct plt_entry **ifunc;
-
/* Set PLT_IFUNC flag for this sym, no GOT entry yet. */
ifunc = update_local_sym_info (abfd, symtab_hdr, r_symndx,
PLT_IFUNC);
#ifdef DEBUG
fprintf (stderr, "Reloc requires a PLT entry\n");
#endif
- /* This symbol requires a procedure linkage table entry. We
- actually build the entry in finish_dynamic_symbol,
- because this might be a case of linking PIC code without
- linking in any dynamic objects, in which case we don't
- need to generate a procedure linkage table after all. */
-
+ /* This symbol requires a procedure linkage table entry. */
if (h == NULL)
{
- /* It does not make sense to have a procedure linkage
- table entry for a local symbol. */
- info->callbacks->einfo (_("%P: %H: %s reloc against local symbol\n"),
- abfd, sec, rel->r_offset,
- ppc_elf_howto_table[r_type]->name);
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
+ if (ifunc == NULL)
+ {
+ /* It does not make sense to have a procedure linkage
+ table entry for a non-ifunc local symbol. */
+ info->callbacks->einfo
+ (_("%P: %H: %s reloc against local symbol\n"),
+ abfd, sec, rel->r_offset,
+ ppc_elf_howto_table[r_type]->name);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
}
else
{
{
if (bfd_link_pic (info))
{
- info->callbacks->einfo (_("%P: %H: @local call to ifunc %s\n"),
- abfd, sec, rel->r_offset,
- h->root.root.string);
+ info->callbacks->einfo
+ (_("%P: %H: @local call to ifunc %s\n"),
+ abfd, sec, rel->r_offset,
+ h->root.root.string);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
case R_PPC_PLTREL24:
if (h != NULL && ifunc == NULL)
{
- struct plt_entry *ent = find_plt_ent (&h->plt.plist, got2,
- bfd_link_pic (info) ? addend : 0);
+ struct plt_entry *ent;
+
+ ent = find_plt_ent (&h->plt.plist, got2,
+ bfd_link_pic (info) ? addend : 0);
if (ent == NULL
|| htab->plt == NULL)
{