mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
Added new files elflink.c, elflink.h, elfcore.h.
Moved some mostly size-independent stuff from elfcode.h to elf.c, adding a data structure to elfcode.h with some misc data and callback functions. Added a pointer to that structure to the target back end data. More work can be done here. Renamed generic elf routines (not cpu-specific stuff) to start with bfd_elf or _bfd_elf. Updated most call sites, sometimes defined some macros. Moved some dynamic linking support code from m68k, sparc, i386 to common files, using target back end flags to control behavior. More work can probably be done here too. Moved core- and linker-support code out of elfcode.h to elf.c, elfcore.h, elflink.h, or elflink.c. Now elfcode.h contains only .o and executable support, plus #includes of elfcore.h and elflink.h. Much of the contents of these other header files can probably still be moved from the .h files to the .c files, to get compiled only once. Cleaned up some "gcc -Wall" warnings regarding unused or uninitialized variables, in generic and cpu-specific code.
This commit is contained in:
parent
80c5739dbe
commit
ede4eed483
@ -141,6 +141,9 @@ elf64-sparc.c
|
||||
elf64.c
|
||||
elfxx-target.h
|
||||
elfcode.h
|
||||
elfcore.h
|
||||
elflink.c
|
||||
elflink.h
|
||||
filemode.c
|
||||
format.c
|
||||
gen-aout.c
|
||||
|
@ -1,3 +1,22 @@
|
||||
Wed Jul 5 20:17:14 1995 Ken Raeburn <raeburn@cygnus.com>
|
||||
|
||||
* elfcore.h, elflink.h, elfcode.h, elf.c, elflink.c: Moved some
|
||||
primarily size-independent code from elfcode.h to elf.c and new
|
||||
file elflink.c; moved out other core- or linker-related routines
|
||||
into other new .h files for clarity. Renamed many routines to
|
||||
start with bfd_elf or _bfd_elf. Added a structure of
|
||||
size-dependent but target-independent info to elfcode.h.
|
||||
* Makefile.in: Build elflink.o. Update dependencies.
|
||||
* libelf.h: Updated some declarations. Added a definition for the
|
||||
new structure in elfcode.h. Added more fields to elf backend data
|
||||
structure.
|
||||
* elfxx-target.h: Refer to the appropriate size-dependent info.
|
||||
* elf32-*.c: Changed some function names. Moved common
|
||||
create_dynamic_sections code from m68k, sparc, and i386 support
|
||||
into elflink.c. Define some new macros to fill in new fields of
|
||||
back end data. Also clean up some "gcc -Wall" warnings regarding
|
||||
unused or uninitialized variables.
|
||||
|
||||
Wed Jul 5 10:31:47 1995 Ian Lance Taylor <ian@cygnus.com>
|
||||
|
||||
* elf32-mips.c (mips_elf_object_p): Unconditionally set
|
||||
|
@ -85,7 +85,7 @@ BFD_LIBS = \
|
||||
archive.o archures.o bfd.o cache.o coffgen.o core.o \
|
||||
format.o init.o libbfd.o opncls.o reloc.o \
|
||||
section.o syms.o targets.o hash.o linker.o \
|
||||
elf.o srec.o binary.o tekhex.o
|
||||
elf.o elflink.o srec.o binary.o tekhex.o
|
||||
|
||||
# This list is alphabetized to make it easier to keep in sync
|
||||
# with the decls and initializer in archures.c.
|
||||
@ -714,7 +714,9 @@ mipsbsd.o: mipsbsd.c libaout.h $(INCDIR)/bfdlink.h \
|
||||
cpu-sh.o: cpu-sh.c
|
||||
elf.o: elf.c $(INCDIR)/bfdlink.h libelf.h $(INCDIR)/elf/common.h \
|
||||
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
|
||||
elf32.o: elf32.c elfcode.h $(INCDIR)/bfdlink.h libelf.h \
|
||||
elflink.o : elflink.c $(INCDIR)/bfdlink.h libelf.h $(INCDIR)/elf/common.h \
|
||||
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
|
||||
elf32.o: elf32.c elfcode.h $(INCDIR)/bfdlink.h libelf.h elfcore.h elflink.h \
|
||||
$(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
|
||||
elf32-sparc.o: elf32-sparc.c $(INCDIR)/bfdlink.h libelf.h \
|
||||
$(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
|
||||
@ -747,7 +749,7 @@ elf32-gen.o: elf32-gen.c libelf.h $(INCDIR)/elf/common.h \
|
||||
elf32-ppc.o: elf32-ppc.c $(INCDIR)/bfdlink.h libelf.h \
|
||||
$(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
|
||||
$(INCDIR)/elf/ppc.h elf32-target.h
|
||||
elf64.o: elf64.c elfcode.h $(INCDIR)/bfdlink.h libelf.h \
|
||||
elf64.o: elf64.c elfcode.h $(INCDIR)/bfdlink.h libelf.h elfcore.h elflink.h \
|
||||
$(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h
|
||||
elf64-gen.o: elf64-gen.c libelf.h $(INCDIR)/elf/common.h \
|
||||
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
|
||||
|
37
bfd/elf32-gen.c
Normal file
37
bfd/elf32-gen.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* Generic support for 32-bit ELF
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "libelf.h"
|
||||
|
||||
/* This does not include any relocations, but should be good enough
|
||||
for GDB to read the file. */
|
||||
|
||||
#define TARGET_LITTLE_SYM bfd_elf32_little_generic_vec
|
||||
#define TARGET_LITTLE_NAME "elf32-little"
|
||||
#define TARGET_BIG_SYM bfd_elf32_big_generic_vec
|
||||
#define TARGET_BIG_NAME "elf32-big"
|
||||
#define ELF_ARCH bfd_arch_unknown
|
||||
#define ELF_MACHINE_CODE EM_NONE
|
||||
#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
|
||||
#define elf_info_to_howto _bfd_elf_no_info_to_howto
|
||||
|
||||
#include "elf32-target.h"
|
@ -865,9 +865,9 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
sym_name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
sym_name = elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
sym_name = bfd_elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
if (sym_name == NULL)
|
||||
return false;
|
||||
if (*sym_name == '\0')
|
||||
@ -1167,8 +1167,8 @@ elf32_hppa_set_section_contents (abfd, section, location, offset, count)
|
||||
if (!strcmp (section->name, ".PARISC.symextn") && !symext_chain_size)
|
||||
return true;
|
||||
else
|
||||
return bfd_elf32_set_section_contents (abfd, section, location,
|
||||
offset, count);
|
||||
return _bfd_elf_set_section_contents (abfd, section, location,
|
||||
offset, count);
|
||||
}
|
||||
|
||||
/* Translate from an elf into field into a howto relocation pointer. */
|
||||
@ -2007,7 +2007,7 @@ elf32_hppa_read_symext_info (input_bfd, symtab_hdr, args_hash_table, local_syms)
|
||||
|
||||
hdr = elf_elfsections (input_bfd)[local_syms[current_index].st_shndx];
|
||||
sym_sec = hdr->bfd_section;
|
||||
sym_name = elf_string_from_elf_section (input_bfd,
|
||||
sym_name = bfd_elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
local_syms[current_index].st_name);
|
||||
len = strlen (sym_name) + 10;
|
||||
@ -2529,7 +2529,7 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info)
|
||||
struct bfd_link_info *link_info;
|
||||
{
|
||||
bfd *input_bfd;
|
||||
asection *section, *stub_sec;
|
||||
asection *section, *stub_sec = 0;
|
||||
Elf_Internal_Shdr *symtab_hdr;
|
||||
Elf_Internal_Sym *local_syms, *isym, **all_local_syms;
|
||||
Elf32_External_Sym *ext_syms, *esym;
|
||||
@ -2803,9 +2803,9 @@ elf32_hppa_size_stubs (stub_bfd, output_bfd, link_info)
|
||||
sym = local_syms + r_index;
|
||||
hdr = elf_elfsections (input_bfd)[sym->st_shndx];
|
||||
sym_sec = hdr->bfd_section;
|
||||
sym_name = elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
sym_name = bfd_elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
sym_value = (ELF_ST_TYPE (sym->st_info) == STT_SECTION
|
||||
? 0 : sym->st_value);
|
||||
destination = (sym_value
|
||||
|
140
bfd/elf32-i386.c
140
bfd/elf32-i386.c
@ -29,10 +29,6 @@ static void elf_i386_info_to_howto
|
||||
PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
|
||||
static void elf_i386_info_to_howto_rel
|
||||
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
|
||||
static boolean elf_i386_create_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean elf_i386_create_got_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean elf_i386_check_relocs
|
||||
PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
||||
const Elf_Internal_Rela *));
|
||||
@ -243,125 +239,6 @@ static const bfd_byte elf_i386_pic_plt_entry[PLT_ENTRY_SIZE] =
|
||||
0, 0, 0, 0 /* replaced with offset to start of .plt. */
|
||||
};
|
||||
|
||||
/* Create dynamic sections when linking against a dynamic object. */
|
||||
|
||||
static boolean
|
||||
elf_i386_create_dynamic_sections (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
|
||||
/* We need to create .plt, .rel.plt, .got, .got.plt, .dynbss, and
|
||||
.rel.bss sections. */
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY | SEC_CODE)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
s = bfd_make_section (abfd, ".rel.plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (! elf_i386_create_got_section (abfd, info))
|
||||
return false;
|
||||
|
||||
/* The .dynbss section is a place to put symbols which are defined
|
||||
by dynamic objects, are referenced by regular objects, and are
|
||||
not functions. We must allocate space for them in the process
|
||||
image and use a R_386_COPY reloc to tell the dynamic linker to
|
||||
initialize them at run time. The linker script puts the .dynbss
|
||||
section into the .bss section of the final image. */
|
||||
s = bfd_make_section (abfd, ".dynbss");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
|
||||
return false;
|
||||
|
||||
/* The .rel.bss section holds copy relocs. This section is not
|
||||
normally needed. We need to create it here, though, so that the
|
||||
linker will map it to an output section. We can't just create it
|
||||
only if we need it, because we will not know whether we need it
|
||||
until we have seen all the input files, and the first time the
|
||||
main linker code calls BFD after examining all the input files
|
||||
(size_dynamic_sections) the input sections have already been
|
||||
mapped to the output sections. If the section turns out not to
|
||||
be needed, we can discard it later. We will never need this
|
||||
section when generating a shared object, since they do not use
|
||||
copy relocs. */
|
||||
if (! info->shared)
|
||||
{
|
||||
s = bfd_make_section (abfd, ".rel.bss");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create the .got section to hold the global offset table, and the
|
||||
.got.plt section to hold procedure linkage table GOT entries. The
|
||||
linker script will put .got.plt into the output .got section. */
|
||||
|
||||
static boolean
|
||||
elf_i386_create_got_section (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
struct elf_link_hash_entry *h;
|
||||
|
||||
/* This function may be called more than once. */
|
||||
if (bfd_get_section_by_name (abfd, ".got") != NULL)
|
||||
return true;
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".got");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
s = bfd_make_section (abfd, ".got.plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
/* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the
|
||||
.got.plt section, which will be placed at the start of the output
|
||||
.got section. We don't do this in the linker script because we
|
||||
don't want to define the symbol if we are not creating a global
|
||||
offset table. */
|
||||
h = NULL;
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
|
||||
(const char *) NULL, false, get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return false;
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! bfd_elf32_link_record_dynamic_symbol (info, h))
|
||||
return false;
|
||||
|
||||
/* The first three global offset table entries are reserved. */
|
||||
s->_raw_size += 3 * 4;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Look through the relocs for a section during the first phase, and
|
||||
allocate space in the global offset table or procedure linkage
|
||||
table. */
|
||||
@ -417,7 +294,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
|
||||
case R_386_GOTOFF:
|
||||
case R_386_GOTPC:
|
||||
elf_hash_table (info)->dynobj = dynobj = abfd;
|
||||
if (! elf_i386_create_got_section (dynobj, info))
|
||||
if (! _bfd_elf_create_got_section (dynobj, info))
|
||||
return false;
|
||||
break;
|
||||
|
||||
@ -549,7 +426,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
name = (elf_string_from_elf_section
|
||||
name = (bfd_elf_string_from_elf_section
|
||||
(abfd,
|
||||
elf_elfheader (abfd)->e_shstrndx,
|
||||
elf_section_data (sec)->rel_hdr.sh_name));
|
||||
@ -1224,7 +1101,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
|
||||
if (sreloc == NULL)
|
||||
{
|
||||
shared_name = (elf_string_from_elf_section
|
||||
shared_name = (bfd_elf_string_from_elf_section
|
||||
(input_bfd,
|
||||
elf_elfheader (input_bfd)->e_shstrndx,
|
||||
elf_section_data (input_section)->rel_hdr.sh_name));
|
||||
@ -1308,9 +1185,9 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
name = bfd_elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
if (name == NULL)
|
||||
return false;
|
||||
if (*name == '\0')
|
||||
@ -1616,7 +1493,7 @@ elf_i386_finish_dynamic_sections (output_bfd, info)
|
||||
#define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup
|
||||
#define ELF_MAXPAGESIZE 0x1000
|
||||
#define elf_backend_create_dynamic_sections \
|
||||
elf_i386_create_dynamic_sections
|
||||
_bfd_elf_create_dynamic_sections
|
||||
#define elf_backend_check_relocs elf_i386_check_relocs
|
||||
#define elf_backend_adjust_dynamic_symbol \
|
||||
elf_i386_adjust_dynamic_symbol
|
||||
@ -1627,5 +1504,8 @@ elf_i386_finish_dynamic_sections (output_bfd, info)
|
||||
elf_i386_finish_dynamic_symbol
|
||||
#define elf_backend_finish_dynamic_sections \
|
||||
elf_i386_finish_dynamic_sections
|
||||
#define elf_backend_want_got_plt 1
|
||||
#define elf_backend_plt_readonly 0
|
||||
#define elf_backend_want_plt_sym 0
|
||||
|
||||
#include "elf32-target.h"
|
||||
|
33
bfd/elf32-i860.c
Normal file
33
bfd/elf32-i860.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* Intel 860 specific support for 32-bit ELF
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "libelf.h"
|
||||
|
||||
#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
|
||||
#define elf_info_to_howto _bfd_elf_no_info_to_howto
|
||||
|
||||
#define TARGET_BIG_SYM bfd_elf32_i860_vec
|
||||
#define TARGET_BIG_NAME "elf32-i860"
|
||||
#define ELF_ARCH bfd_arch_i860
|
||||
#define ELF_MACHINE_CODE EM_860
|
||||
|
||||
#include "elf32-target.h"
|
140
bfd/elf32-m68k.c
140
bfd/elf32-m68k.c
@ -29,10 +29,6 @@ static void rtype_to_howto
|
||||
PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
|
||||
static void rtype_to_howto_rel
|
||||
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
|
||||
static boolean elf_m68k_create_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean elf_m68k_create_got_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean elf_m68k_check_relocs
|
||||
PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
||||
const Elf_Internal_Rela *));
|
||||
@ -211,125 +207,6 @@ static const bfd_byte elf_m68k_plt_entry[PLT_ENTRY_SIZE] =
|
||||
0, 0, 0, 0 /* replaced with offset to start of .plt. */
|
||||
};
|
||||
|
||||
/* Create dynamic sections when linking against a dynamic object. */
|
||||
|
||||
static boolean
|
||||
elf_m68k_create_dynamic_sections (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
|
||||
/* We need to create .plt, .rela.plt, .got, .got.plt, .dynbss, and
|
||||
.rela.bss sections. */
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".plt");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags | SEC_READONLY | SEC_CODE)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
s = bfd_make_section (abfd, ".rela.plt");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (!elf_m68k_create_got_section (abfd, info))
|
||||
return false;
|
||||
|
||||
/* The .dynbss section is a place to put symbols which are defined
|
||||
by dynamic objects, are referenced by regular objects, and are
|
||||
not functions. We must allocate space for them in the process
|
||||
image and use a R_68K_COPY reloc to tell the dynamic linker to
|
||||
initialize them at run time. The linker script puts the .dynbss
|
||||
section into the .bss section of the final image. */
|
||||
s = bfd_make_section (abfd, ".dynbss");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, SEC_ALLOC))
|
||||
return false;
|
||||
|
||||
/* The .rela.bss section holds copy relocs. This section is not
|
||||
normally needed. We need to create it here, though, so that the
|
||||
linker will map it to an output section. We can't just create it
|
||||
only if we need it, because we will not know whether we need it
|
||||
until we have seen all the input files, and the first time the
|
||||
main linker code calls BFD after examining all the input files
|
||||
(size_dynamic_sections) the input sections have already been
|
||||
mapped to the output sections. If the section turns out not to
|
||||
be needed, we can discard it later. We will never need this
|
||||
section when generating a shared object, since they do not use
|
||||
copy relocs. */
|
||||
if (!info->shared)
|
||||
{
|
||||
s = bfd_make_section (abfd, ".rela.bss");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create the .got section to hold the global offset table, and the
|
||||
.got.plt section to hold procedure linkage table GOT entries. The
|
||||
linker script will put .got.plt into the output .got section. */
|
||||
|
||||
static boolean
|
||||
elf_m68k_create_got_section (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
struct elf_link_hash_entry *h;
|
||||
|
||||
/* This function may be called more than once. */
|
||||
if (bfd_get_section_by_name (abfd, ".got") != NULL)
|
||||
return true;
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".got");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
s = bfd_make_section (abfd, ".got.plt");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
/* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the
|
||||
.got.plt section, which will be placed at the start of the output
|
||||
.got section. We don't do this in the linker script because we
|
||||
don't want to define the symbol if we are not creating a global
|
||||
offset table. */
|
||||
h = NULL;
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
|
||||
(const char *) NULL, false, get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return false;
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& !bfd_elf32_link_record_dynamic_symbol (info, h))
|
||||
return false;
|
||||
|
||||
/* The first three global offset table entries are reserved. */
|
||||
s->_raw_size += 3 * 4;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Look through the relocs for a section during the first phase, and
|
||||
allocate space in the global offset table or procedure linkage
|
||||
table. */
|
||||
@ -394,7 +271,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
|
||||
{
|
||||
/* Create the .got section. */
|
||||
elf_hash_table (info)->dynobj = dynobj = abfd;
|
||||
if (!elf_m68k_create_got_section (dynobj, info))
|
||||
if (!_bfd_elf_create_got_section (dynobj, info))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -523,7 +400,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
name = (elf_string_from_elf_section
|
||||
name = (bfd_elf_string_from_elf_section
|
||||
(abfd,
|
||||
elf_elfheader (abfd)->e_shstrndx,
|
||||
elf_section_data (sec)->rel_hdr.sh_name));
|
||||
@ -1275,7 +1152,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
{
|
||||
const char *name;
|
||||
|
||||
name = (elf_string_from_elf_section
|
||||
name = (bfd_elf_string_from_elf_section
|
||||
(input_bfd,
|
||||
elf_elfheader (input_bfd)->e_shstrndx,
|
||||
elf_section_data (input_section)->rel_hdr.sh_name));
|
||||
@ -1374,9 +1251,9 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
name = bfd_elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
if (name == NULL)
|
||||
return false;
|
||||
if (*name == '\0')
|
||||
@ -1674,7 +1551,7 @@ elf_m68k_finish_dynamic_sections (output_bfd, info)
|
||||
#define ELF_MACHINE_CODE EM_68K
|
||||
#define ELF_MAXPAGESIZE 0x2000
|
||||
#define elf_backend_create_dynamic_sections \
|
||||
elf_m68k_create_dynamic_sections
|
||||
_bfd_elf_create_dynamic_sections
|
||||
#define elf_backend_check_relocs elf_m68k_check_relocs
|
||||
#define elf_backend_adjust_dynamic_symbol \
|
||||
elf_m68k_adjust_dynamic_symbol
|
||||
@ -1685,5 +1562,8 @@ elf_m68k_finish_dynamic_sections (output_bfd, info)
|
||||
elf_m68k_finish_dynamic_symbol
|
||||
#define elf_backend_finish_dynamic_sections \
|
||||
elf_m68k_finish_dynamic_sections
|
||||
#define elf_backend_want_got_plt 1
|
||||
#define elf_backend_plt_readonly 1
|
||||
#define elf_backend_want_plt_sym 0
|
||||
|
||||
#include "elf32-target.h"
|
||||
|
35
bfd/elf32-m88k.c
Normal file
35
bfd/elf32-m88k.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* Motorola 88k-specific support for 32-bit ELF
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
#include "libelf.h"
|
||||
|
||||
/* This does not include any relocations, but should be good enough
|
||||
for GDB. */
|
||||
|
||||
#define TARGET_BIG_SYM bfd_elf32_m88k_vec
|
||||
#define TARGET_BIG_NAME "elf32-m88k"
|
||||
#define ELF_ARCH bfd_arch_m88k
|
||||
#define ELF_MACHINE_CODE EM_88K
|
||||
#define bfd_elf32_bfd_reloc_type_lookup bfd_default_reloc_type_lookup
|
||||
#define elf_info_to_howto _bfd_elf_no_info_to_howto
|
||||
|
||||
#include "elf32-target.h"
|
@ -1587,9 +1587,9 @@ mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
|
||||
|
||||
/* Fall back on the generic ELF find_nearest_line routine. */
|
||||
|
||||
return bfd_elf32_find_nearest_line (abfd, section, symbols, offset,
|
||||
filename_ptr, functionname_ptr,
|
||||
line_ptr);
|
||||
return _bfd_elf_find_nearest_line (abfd, section, symbols, offset,
|
||||
filename_ptr, functionname_ptr,
|
||||
line_ptr);
|
||||
}
|
||||
|
||||
/* The MIPS ELF linker needs additional information for each symbol in
|
||||
@ -2713,9 +2713,9 @@ mips_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
name = bfd_elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
if (name == NULL)
|
||||
return false;
|
||||
if (*name == '\0')
|
||||
@ -2788,7 +2788,7 @@ elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data,
|
||||
arelent **parent;
|
||||
/* for mips */
|
||||
int gp_found;
|
||||
bfd_vma gp;
|
||||
bfd_vma gp = 0x12345678; /* initialize just to shut gcc up */
|
||||
|
||||
{
|
||||
struct bfd_hash_entry *h;
|
||||
|
654
bfd/elf32-ppc.c
654
bfd/elf32-ppc.c
@ -25,19 +25,39 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "bfdlink.h"
|
||||
#include "libbfd.h"
|
||||
#include "libelf.h"
|
||||
#include "elf/ppc.h"
|
||||
|
||||
static bfd_reloc_status_type ppc_elf_unsupported_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_reloc_status_type ppc_elf_std_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
|
||||
static bfd_vma ppc_elf_addr16_ha_inner PARAMS ((asection *, bfd_vma, bfd_vma));
|
||||
static bfd_reloc_status_type ppc_elf_addr16_ha_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static bfd_vma ppc_elf_got16_inner PARAMS ((asection *sec));
|
||||
static bfd_reloc_status_type ppc_elf_got16_reloc
|
||||
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
||||
static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
|
||||
static reloc_howto_type *ppc_elf_reloc_type_lookup
|
||||
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
|
||||
static void powerpc_info_to_howto
|
||||
static void ppc_elf_info_to_howto
|
||||
PARAMS ((bfd *abfd, arelent *cache_ptr, Elf32_Internal_Rela *dst));
|
||||
static void ppc_elf_howto_init PARAMS ((void));
|
||||
static boolean ppc_elf_set_private_flags PARAMS ((bfd *, flagword));
|
||||
static boolean ppc_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
|
||||
static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
|
||||
|
||||
static boolean ppc_elf_relocate_section PARAMS ((bfd *,
|
||||
struct bfd_link_info *info,
|
||||
bfd *,
|
||||
asection *,
|
||||
bfd_byte *,
|
||||
Elf_Internal_Rela *relocs,
|
||||
Elf_Internal_Sym *local_syms,
|
||||
asection **));
|
||||
|
||||
#define USE_RELA
|
||||
|
||||
@ -104,7 +124,10 @@ enum reloc_type
|
||||
R_PPC_max
|
||||
};
|
||||
|
||||
static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
|
||||
static reloc_howto_type *ppc_elf_howto_table[ (int)R_PPC_max ];
|
||||
|
||||
static reloc_howto_type ppc_elf_howto_raw[] =
|
||||
{
|
||||
/* This reloc does nothing. */
|
||||
HOWTO (R_PPC_NONE, /* type */
|
||||
@ -114,7 +137,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_NONE", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -129,7 +152,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_ADDR32", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -145,7 +168,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_ADDR24", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -160,7 +183,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_ADDR16", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -175,7 +198,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont,/* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_ADDR16_LO", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -190,7 +213,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_dont, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_ADDR16_HI", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -222,7 +245,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_ADDR14", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -271,7 +294,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_REL24", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -286,7 +309,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_REL14", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -335,7 +358,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
16, /* bitsize */
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
ppc_elf_got16_reloc, /* special_function */
|
||||
"R_PPC_GOT16", /* name */
|
||||
false, /* partial_inplace */
|
||||
@ -400,7 +423,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_signed, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_PLT24", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -419,7 +442,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_COPY", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -435,7 +458,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_GLOB_DAT", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -450,7 +473,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_JMP_SLOT", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -467,7 +490,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_RELATIVE", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -499,7 +522,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_UADDR32", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -514,7 +537,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_UADDR16", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -529,7 +552,7 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
true, /* pc_relative */
|
||||
0, /* bitpos */
|
||||
complain_overflow_bitfield, /* complain_on_overflow */
|
||||
bfd_elf_generic_reloc, /* special_function */
|
||||
ppc_elf_std_reloc, /* special_function */
|
||||
"R_PPC_REL32", /* name */
|
||||
false, /* partial_inplace */
|
||||
0, /* src_mask */
|
||||
@ -774,6 +797,224 @@ static reloc_howto_type elf_powerpc_howto_table[] =
|
||||
false), /* pcrel_offset */
|
||||
};
|
||||
|
||||
|
||||
/* Initialize the ppc_elf_howto_table, so that linear accesses can be done. */
|
||||
|
||||
static void
|
||||
ppc_elf_howto_init ()
|
||||
{
|
||||
unsigned int i, type;
|
||||
|
||||
for (i = 0; i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); i++)
|
||||
{
|
||||
type = ppc_elf_howto_raw[i].type;
|
||||
BFD_ASSERT (type < sizeof(ppc_elf_howto_table) / sizeof(ppc_elf_howto_table[0]));
|
||||
ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static reloc_howto_type *
|
||||
ppc_elf_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
|
||||
ppc_elf_howto_init ();
|
||||
|
||||
switch ((int)code)
|
||||
{
|
||||
case BFD_RELOC_NONE: return ppc_elf_howto_table[ (int) R_PPC_NONE ];
|
||||
case BFD_RELOC_32: return ppc_elf_howto_table[ (int) R_PPC_ADDR32 ];
|
||||
case BFD_RELOC_32_PCREL: return ppc_elf_howto_table[ (int) R_PPC_REL32 ];
|
||||
case BFD_RELOC_CTOR: return ppc_elf_howto_table[ (int) R_PPC_ADDR32 ];
|
||||
case BFD_RELOC_PPC_B26: return ppc_elf_howto_table[ (int) R_PPC_REL24 ];
|
||||
case BFD_RELOC_PPC_BA26: return ppc_elf_howto_table[ (int) R_PPC_ADDR24 ];
|
||||
case BFD_RELOC_PPC_TOC16: return ppc_elf_howto_table[ (int) R_PPC_GOT16 ];
|
||||
case BFD_RELOC_LO16: return ppc_elf_howto_table[ (int) R_PPC_ADDR16_LO ];
|
||||
case BFD_RELOC_HI16: return ppc_elf_howto_table[ (int) R_PPC_ADDR16_HI ];
|
||||
case BFD_RELOC_HI16_S: return ppc_elf_howto_table[ (int) R_PPC_ADDR16_HA ];
|
||||
}
|
||||
|
||||
return (reloc_howto_type *)NULL;
|
||||
};
|
||||
|
||||
/* Set the howto pointer for a PowerPC ELF reloc. */
|
||||
|
||||
static void
|
||||
ppc_elf_info_to_howto (abfd, cache_ptr, dst)
|
||||
bfd *abfd;
|
||||
arelent *cache_ptr;
|
||||
Elf32_Internal_Rela *dst;
|
||||
{
|
||||
if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
|
||||
ppc_elf_howto_init ();
|
||||
|
||||
BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max);
|
||||
cache_ptr->howto = ppc_elf_howto_table[ELF32_R_TYPE (dst->r_info)];
|
||||
}
|
||||
|
||||
/* Function to set whether a module needs the -mrelocatable bit set. */
|
||||
|
||||
static boolean
|
||||
ppc_elf_set_private_flags (abfd, flags)
|
||||
bfd *abfd;
|
||||
flagword flags;
|
||||
{
|
||||
BFD_ASSERT (!elf_ppc_flags_init (abfd)
|
||||
|| elf_elfheader (abfd)->e_flags == flags);
|
||||
|
||||
elf_elfheader (abfd)->e_flags = flags;
|
||||
elf_ppc_flags_init (abfd) = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Copy backend specific data from one object module to another */
|
||||
static boolean
|
||||
ppc_elf_copy_private_bfd_data (ibfd, obfd)
|
||||
bfd *ibfd;
|
||||
bfd *obfd;
|
||||
{
|
||||
/* This function is selected based on the input vector. We only
|
||||
want to copy information over if the output BFD also uses Elf
|
||||
format. */
|
||||
if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
|
||||
return true;
|
||||
|
||||
BFD_ASSERT (!elf_ppc_flags_init (obfd)
|
||||
|| elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
|
||||
|
||||
elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
|
||||
elf_ppc_flags_init (obfd) = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Merge backend specific data from an object file to the output
|
||||
object file when linking */
|
||||
static boolean
|
||||
ppc_elf_merge_private_bfd_data (ibfd, obfd)
|
||||
bfd *ibfd;
|
||||
bfd *obfd;
|
||||
{
|
||||
flagword old_flags;
|
||||
flagword new_flags;
|
||||
|
||||
/* Check if we have the same endianess */
|
||||
if (ibfd->xvec->byteorder_big_p != obfd->xvec->byteorder_big_p)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: compiled for a %s endian system and target is %s endian.\n",
|
||||
bfd_get_filename (ibfd),
|
||||
(ibfd->xvec->byteorder_big_p) ? "big" : "little",
|
||||
(obfd->xvec->byteorder_big_p) ? "big" : "little");
|
||||
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This function is selected based on the input vector. We only
|
||||
want to copy information over if the output BFD also uses Elf
|
||||
format. */
|
||||
if (bfd_get_flavour (obfd) != bfd_target_elf_flavour)
|
||||
return true;
|
||||
|
||||
new_flags = elf_elfheader (ibfd)->e_flags;
|
||||
old_flags = elf_elfheader (obfd)->e_flags;
|
||||
if (!elf_ppc_flags_init (obfd)) /* First call, no flags set */
|
||||
{
|
||||
elf_ppc_flags_init (obfd) = true;
|
||||
elf_elfheader (obfd)->e_flags = new_flags;
|
||||
}
|
||||
|
||||
else if (new_flags == old_flags) /* Compatible flags are ok */
|
||||
;
|
||||
|
||||
else /* Incompatible flags */
|
||||
{
|
||||
/* Warn about -mrelocatable mismatch */
|
||||
if ((new_flags & EF_PPC_RELOCATABLE) != 0 && (old_flags & EF_PPC_RELOCATABLE) == 0)
|
||||
{
|
||||
new_flags &= ~EF_PPC_RELOCATABLE;
|
||||
fprintf (stderr,
|
||||
"%s: compiled with -mrelocatable and linked with modules compiled normally\n",
|
||||
bfd_get_filename (ibfd));
|
||||
}
|
||||
else if ((new_flags & EF_PPC_RELOCATABLE) == 0 && (old_flags & EF_PPC_RELOCATABLE) != 0)
|
||||
{
|
||||
old_flags &= ~EF_PPC_RELOCATABLE;
|
||||
fprintf (stderr,
|
||||
"%s: compiled normally and linked with modules compiled with -mrelocatable\n",
|
||||
bfd_get_filename (ibfd));
|
||||
}
|
||||
|
||||
/* Warn about eabi vs. V.4 mismatch */
|
||||
if ((new_flags & EF_PPC_EMB) != 0 && (old_flags & EF_PPC_EMB) == 0)
|
||||
{
|
||||
new_flags &= ~EF_PPC_EMB;
|
||||
fprintf (stderr,
|
||||
"%s: compiled for the eabi and linked with modules compiled for System V\n",
|
||||
bfd_get_filename (ibfd));
|
||||
}
|
||||
else if ((new_flags & EF_PPC_EMB) == 0 && (old_flags & EF_PPC_EMB) != 0)
|
||||
{
|
||||
old_flags &= ~EF_PPC_EMB;
|
||||
fprintf (stderr,
|
||||
"%s: compiled for System V and linked with modules compiled for eabi\n",
|
||||
bfd_get_filename (ibfd));
|
||||
}
|
||||
|
||||
/* Warn about any other mismatches */
|
||||
if (new_flags != old_flags)
|
||||
fprintf (stderr,
|
||||
"%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)\n",
|
||||
bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
|
||||
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* ELF relocs are against symbols. If we are producing relocateable
|
||||
output, and the reloc is against an external symbol, and nothing
|
||||
has given us any additional addend, the resulting reloc will also
|
||||
be against the same symbol. In such a case, we don't want to
|
||||
change anything about the way the reloc is handled, since it will
|
||||
all be done at final link time. Rather than put special case code
|
||||
into bfd_perform_relocation, all the reloc types use this howto
|
||||
function. It just short circuits the reloc if producing
|
||||
relocateable output against an external symbol. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static bfd_reloc_status_type
|
||||
ppc_elf_std_reloc (abfd,
|
||||
reloc_entry,
|
||||
symbol,
|
||||
data,
|
||||
input_section,
|
||||
output_bfd,
|
||||
error_message)
|
||||
bfd *abfd;
|
||||
arelent *reloc_entry;
|
||||
asymbol *symbol;
|
||||
PTR data;
|
||||
asection *input_section;
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
if (output_bfd != (bfd *) NULL
|
||||
&& (symbol->flags & BSF_SECTION_SYM) == 0
|
||||
&& (! reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
|
||||
{
|
||||
reloc_entry->address += input_section->output_offset;
|
||||
return bfd_reloc_ok;
|
||||
}
|
||||
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* Don't pretend we can deal with unsupported relocs. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
@ -788,11 +1029,39 @@ ppc_elf_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
abort ();
|
||||
BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
|
||||
fprintf (stderr,
|
||||
"%s: Relocation %s (%d) is not currently supported.\n",
|
||||
bfd_get_filename (abfd),
|
||||
reloc_entry->howto->name,
|
||||
reloc_entry->howto->type);
|
||||
|
||||
return bfd_reloc_notsupported;
|
||||
}
|
||||
|
||||
/* Internal function to return the adjustment to the addend for relocations
|
||||
that return the upper 16 bits after sign extending the lower 16 bits, ie
|
||||
for use with a ORIS instruction followed by a memory reference using the
|
||||
bottom 16 bits. */
|
||||
|
||||
INLINE
|
||||
static bfd_vma
|
||||
ppc_elf_addr16_ha_inner (sec, value, addend)
|
||||
asection *sec;
|
||||
bfd_vma value;
|
||||
bfd_vma addend;
|
||||
{
|
||||
bfd_vma relocation = (value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ addend);
|
||||
|
||||
return (relocation & 0x8000) << 1;
|
||||
}
|
||||
|
||||
/* Handle the ADDR16_HA reloc by adjusting the reloc addend. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static bfd_reloc_status_type
|
||||
ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
@ -804,33 +1073,38 @@ ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
bfd_vma relocation;
|
||||
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
|
||||
input_section, output_bfd, error_message);
|
||||
|
||||
if (bfd_is_com_section (symbol->section))
|
||||
relocation = 0;
|
||||
else
|
||||
relocation = symbol->value;
|
||||
|
||||
relocation += (symbol->section->output_section->vma
|
||||
+ symbol->section->output_offset
|
||||
+ reloc_entry->addend);
|
||||
|
||||
if ((relocation & 0x8000) != 0)
|
||||
reloc_entry->addend += 0x10000;
|
||||
return ppc_elf_std_reloc (abfd, reloc_entry, symbol, data,
|
||||
input_section, output_bfd, error_message);
|
||||
|
||||
reloc_entry->addend += ppc_elf_addr16_ha_inner (symbol->section,
|
||||
(bfd_is_com_section (symbol->section)) ? 0 : symbol->value,
|
||||
reloc_entry->addend);
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* Internal function to return the addjustment to the addend for GOT16
|
||||
entries */
|
||||
|
||||
INLINE
|
||||
static bfd_vma
|
||||
ppc_elf_got16_inner (sec)
|
||||
asection *sec;
|
||||
{
|
||||
BFD_ASSERT (bfd_is_und_section (sec)
|
||||
|| strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
|
||||
|| strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0);
|
||||
|
||||
return -(sec->output_section->vma + 0x8000);
|
||||
}
|
||||
|
||||
/* Handle the GOT16 reloc. We want to use the offset within the .got
|
||||
section, not the actual VMA. This is appropriate when generating
|
||||
an embedded ELF object, for which the .got section acts like the
|
||||
AIX .toc section. When and if we support PIC code, we will have to
|
||||
change this, perhaps by switching off on the e_type field. */
|
||||
|
||||
/*ARGSUSED*/
|
||||
static bfd_reloc_status_type
|
||||
ppc_elf_got16_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
output_bfd, error_message)
|
||||
@ -842,78 +1116,272 @@ ppc_elf_got16_reloc (abfd, reloc_entry, symbol, data, input_section,
|
||||
bfd *output_bfd;
|
||||
char **error_message;
|
||||
{
|
||||
asection *sec;
|
||||
|
||||
if (output_bfd != (bfd *) NULL)
|
||||
return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
|
||||
input_section, output_bfd, error_message);
|
||||
return ppc_elf_std_reloc (abfd, reloc_entry, symbol, data,
|
||||
input_section, output_bfd, error_message);
|
||||
|
||||
sec = bfd_get_section (*reloc_entry->sym_ptr_ptr);
|
||||
BFD_ASSERT (bfd_is_und_section (sec)
|
||||
|| strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
|
||||
|| strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0);
|
||||
reloc_entry->addend -= sec->output_section->vma;
|
||||
reloc_entry->addend += ppc_elf_got16_inner (bfd_get_section (*reloc_entry->sym_ptr_ptr));
|
||||
return bfd_reloc_continue;
|
||||
}
|
||||
|
||||
/* Map BFD reloc types to PowerPC ELF reloc types. */
|
||||
|
||||
/* The RELOCATE_SECTION function is called by the ELF backend linker
|
||||
to handle the relocations for a section.
|
||||
|
||||
struct powerpc_reloc_map
|
||||
The relocs are always passed as Rela structures; if the section
|
||||
actually uses Rel structures, the r_addend field will always be
|
||||
zero.
|
||||
|
||||
This function is responsible for adjust the section contents as
|
||||
necessary, and (if using Rela relocs and generating a
|
||||
relocateable output file) adjusting the reloc addend as
|
||||
necessary.
|
||||
|
||||
This function does not have to worry about setting the reloc
|
||||
address or the reloc symbol index.
|
||||
|
||||
LOCAL_SYMS is a pointer to the swapped in local symbols.
|
||||
|
||||
LOCAL_SECTIONS is an array giving the section in the input file
|
||||
corresponding to the st_shndx field of each local symbol.
|
||||
|
||||
The global hash table entry for the global symbols can be found
|
||||
via elf_sym_hashes (input_bfd).
|
||||
|
||||
When generating relocateable output, this function must handle
|
||||
STB_LOCAL/STT_SECTION symbols specially. The output symbol is
|
||||
going to be the section symbol corresponding to the output
|
||||
section, which means that the addend must be adjusted
|
||||
accordingly. */
|
||||
|
||||
static boolean
|
||||
ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
contents, relocs, local_syms, local_sections)
|
||||
bfd *output_bfd;
|
||||
struct bfd_link_info *info;
|
||||
bfd *input_bfd;
|
||||
asection *input_section;
|
||||
bfd_byte *contents;
|
||||
Elf_Internal_Rela *relocs;
|
||||
Elf_Internal_Sym *local_syms;
|
||||
asection **local_sections;
|
||||
{
|
||||
unsigned char bfd_reloc_val;
|
||||
unsigned char elf_reloc_val;
|
||||
};
|
||||
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
|
||||
struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
|
||||
Elf_Internal_Rela *rel = relocs;
|
||||
Elf_Internal_Rela *relend = relocs + input_section->reloc_count;
|
||||
boolean ret = true;
|
||||
|
||||
static const struct powerpc_reloc_map powerpc_reloc_map[] =
|
||||
{
|
||||
{ BFD_RELOC_NONE, R_PPC_NONE, },
|
||||
{ BFD_RELOC_32, R_PPC_ADDR32 },
|
||||
{ BFD_RELOC_32_PCREL, R_PPC_REL32 },
|
||||
{ BFD_RELOC_CTOR, R_PPC_ADDR32 },
|
||||
{ BFD_RELOC_PPC_B26, R_PPC_REL24 },
|
||||
{ BFD_RELOC_PPC_BA26, R_PPC_ADDR24 },
|
||||
{ BFD_RELOC_PPC_TOC16, R_PPC_GOT16 },
|
||||
{ BFD_RELOC_LO16, R_PPC_ADDR16_LO },
|
||||
{ BFD_RELOC_HI16, R_PPC_ADDR16_HI },
|
||||
{ BFD_RELOC_HI16_S, R_PPC_ADDR16_HA }
|
||||
};
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "ppc_elf_relocate_section called for %s section %s, %ld relocations%s\n",
|
||||
bfd_get_filename (input_bfd),
|
||||
bfd_section_name(input_bfd, input_section),
|
||||
(long)input_section->reloc_count,
|
||||
(info->relocateable) ? " (relocatable)" : "");
|
||||
#endif
|
||||
|
||||
static reloc_howto_type *
|
||||
bfd_elf32_bfd_reloc_type_lookup (abfd, code)
|
||||
bfd *abfd;
|
||||
bfd_reloc_code_real_type code;
|
||||
{
|
||||
int i;
|
||||
if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
|
||||
ppc_elf_howto_init ();
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof (powerpc_reloc_map) / sizeof (struct powerpc_reloc_map);
|
||||
i++)
|
||||
for (; rel < relend; rel++)
|
||||
{
|
||||
if (powerpc_reloc_map[i].bfd_reloc_val == code)
|
||||
return &elf_powerpc_howto_table[powerpc_reloc_map[i].elf_reloc_val];
|
||||
enum reloc_type r_type = (enum reloc_type)ELF32_R_TYPE (rel->r_info);
|
||||
bfd_vma offset = rel->r_offset;
|
||||
bfd_vma addend = rel->r_addend;
|
||||
bfd_reloc_status_type r = bfd_reloc_other;
|
||||
Elf_Internal_Sym *sym = (Elf_Internal_Sym *)0;
|
||||
asection *sec = (asection *)0;
|
||||
struct elf_link_hash_entry *h = (struct elf_link_hash_entry *)0;
|
||||
reloc_howto_type *howto;
|
||||
unsigned long r_symndx;
|
||||
bfd_vma relocation;
|
||||
|
||||
/* Unknown relocation handling */
|
||||
if ((unsigned)r_type >= (unsigned)R_PPC_max || !ppc_elf_howto_table[(int)r_type])
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: Unknown relocation type %d\n",
|
||||
bfd_get_filename (input_bfd),
|
||||
(int)r_type);
|
||||
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
ret = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
howto = ppc_elf_howto_table[(int)r_type];
|
||||
r_symndx = ELF32_R_SYM (rel->r_info);
|
||||
|
||||
if (info->relocateable)
|
||||
{
|
||||
/* This is a relocateable link. We don't have to change
|
||||
anything, unless the reloc is against a section symbol,
|
||||
in which case we have to adjust according to where the
|
||||
section symbol winds up in the output section. */
|
||||
if (r_symndx < symtab_hdr->sh_info)
|
||||
{
|
||||
sym = local_syms + r_symndx;
|
||||
if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION)
|
||||
{
|
||||
sec = local_sections[r_symndx];
|
||||
addend = rel->r_addend += sec->output_offset + sym->st_value;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
|
||||
howto->name,
|
||||
(int)r_type,
|
||||
r_symndx,
|
||||
(long)offset,
|
||||
(long)addend);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This is a final link. */
|
||||
|
||||
/* Complain about known relocation that are not yet supported */
|
||||
if (howto->special_function == ppc_elf_unsupported_reloc)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: Relocation %s (%d) is not currently supported.\n",
|
||||
bfd_get_filename (input_bfd),
|
||||
howto->name,
|
||||
(int)r_type);
|
||||
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
ret = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r_symndx < symtab_hdr->sh_info)
|
||||
{
|
||||
sym = local_syms + r_symndx;
|
||||
sec = local_sections[r_symndx];
|
||||
relocation = (sec->output_section->vma
|
||||
+ sec->output_offset
|
||||
+ sym->st_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
{
|
||||
sec = h->root.u.def.section;
|
||||
relocation = (h->root.u.def.value
|
||||
+ sec->output_section->vma
|
||||
+ sec->output_offset);
|
||||
}
|
||||
else if (h->root.type == bfd_link_hash_undefweak)
|
||||
relocation = 0;
|
||||
else if (info->shared)
|
||||
relocation = 0;
|
||||
else
|
||||
{
|
||||
(*info->callbacks->undefined_symbol)(info,
|
||||
h->root.root.string,
|
||||
input_bfd,
|
||||
input_section,
|
||||
rel->r_offset);
|
||||
ret = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
switch ((int)r_type)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case (int)R_PPC_GOT16: /* GOT16 relocations */
|
||||
case (int)R_PPC_GOT16_LO:
|
||||
case (int)R_PPC_GOT16_HI:
|
||||
BFD_ASSERT (sec != (asection *)0);
|
||||
addend += ppc_elf_got16_inner (sec);
|
||||
break;
|
||||
|
||||
case (int)R_PPC_ADDR16_HA: /* arithmetic adjust relocations */
|
||||
BFD_ASSERT (sec != (asection *)0);
|
||||
addend += ppc_elf_addr16_ha_inner (sec, relocation, addend);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
|
||||
howto->name,
|
||||
(int)r_type,
|
||||
r_symndx,
|
||||
(long)offset,
|
||||
(long)addend);
|
||||
#endif
|
||||
|
||||
r = _bfd_final_link_relocate (howto,
|
||||
input_bfd,
|
||||
input_section,
|
||||
contents,
|
||||
offset,
|
||||
relocation,
|
||||
addend);
|
||||
|
||||
if (r != bfd_reloc_ok)
|
||||
{
|
||||
ret = false;
|
||||
switch (r)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
|
||||
case bfd_reloc_overflow:
|
||||
{
|
||||
const char *name;
|
||||
|
||||
if (h != NULL)
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = bfd_elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
if (name == NULL)
|
||||
break;
|
||||
|
||||
if (*name == '\0')
|
||||
name = bfd_section_name (input_bfd, sec);
|
||||
}
|
||||
|
||||
(*info->callbacks->reloc_overflow)(info,
|
||||
name,
|
||||
howto->name,
|
||||
(bfd_vma) 0,
|
||||
input_bfd,
|
||||
input_section,
|
||||
offset);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set the howto pointer for a PowerPC ELF reloc. */
|
||||
|
||||
static void
|
||||
powerpc_info_to_howto (abfd, cache_ptr, dst)
|
||||
bfd *abfd;
|
||||
arelent *cache_ptr;
|
||||
Elf32_Internal_Rela *dst;
|
||||
{
|
||||
BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max);
|
||||
cache_ptr->howto = &elf_powerpc_howto_table[ELF32_R_TYPE (dst->r_info)];
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "\n");
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec
|
||||
#define TARGET_LITTLE_NAME "elf32-powerpcle"
|
||||
#define TARGET_BIG_SYM bfd_elf32_powerpc_vec
|
||||
#define TARGET_BIG_NAME "elf32-powerpc"
|
||||
#define ELF_ARCH bfd_arch_powerpc
|
||||
#define ELF_MACHINE_CODE EM_PPC
|
||||
#define ELF_MAXPAGESIZE 0x10000
|
||||
#define elf_info_to_howto powerpc_info_to_howto
|
||||
#define elf_info_to_howto ppc_elf_info_to_howto
|
||||
|
||||
#ifdef EM_CYGNUS_POWERPC
|
||||
#define ELF_MACHINE_ALT1 EM_CYGNUS_POWERPC
|
||||
@ -923,4 +1391,10 @@ powerpc_info_to_howto (abfd, cache_ptr, dst)
|
||||
#define ELF_MACHINE_ALT2 EM_PPC_OLD
|
||||
#endif
|
||||
|
||||
#define bfd_elf32_bfd_copy_private_bfd_data ppc_elf_copy_private_bfd_data
|
||||
#define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data
|
||||
#define bfd_elf32_bfd_set_private_flags ppc_elf_set_private_flags
|
||||
#define bfd_elf32_bfd_reloc_type_lookup ppc_elf_reloc_type_lookup
|
||||
#define elf_backend_relocate_section ppc_elf_relocate_section
|
||||
|
||||
#include "elf32-target.h"
|
||||
|
@ -27,10 +27,6 @@ static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
|
||||
PARAMS ((bfd *, bfd_reloc_code_real_type));
|
||||
static void elf_info_to_howto
|
||||
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
|
||||
static boolean elf32_sparc_create_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean elf32_sparc_create_got_section
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
static boolean elf32_sparc_check_relocs
|
||||
PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
||||
const Elf_Internal_Rela *));
|
||||
@ -199,124 +195,6 @@ elf_info_to_howto (abfd, cache_ptr, dst)
|
||||
/* nop. */
|
||||
#define PLT_ENTRY_WORD2 SPARC_NOP
|
||||
|
||||
/* Create dynamic sections when linking against a dynamic object. */
|
||||
|
||||
static boolean
|
||||
elf32_sparc_create_dynamic_sections (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
struct elf_link_hash_entry *h;
|
||||
|
||||
/* We need to create .plt, .rela.plt, .got, .dynbss, and .rela.bss
|
||||
sections. */
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
h = NULL;
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
|
||||
(const char *) NULL, false, get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return false;
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! bfd_elf32_link_record_dynamic_symbol (info, h))
|
||||
return false;
|
||||
|
||||
s = bfd_make_section (abfd, ".rela.plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (! elf32_sparc_create_got_section (abfd, info))
|
||||
return false;
|
||||
|
||||
/* The .dynbss section is a place to put symbols which are defined
|
||||
by dynamic objects, are referenced by regular objects, and are
|
||||
not functions. We must allocate space for them in the process
|
||||
image and use a R_SPARC_COPY reloc to tell the dynamic linker to
|
||||
initialize them at run time. The linker script puts the .dynbss
|
||||
section into the .bss section of the final image. */
|
||||
s = bfd_make_section (abfd, ".dynbss");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
|
||||
return false;
|
||||
|
||||
/* The .rela.bss section holds copy relocs. */
|
||||
if (! info->shared)
|
||||
{
|
||||
s = bfd_make_section (abfd, ".rela.bss");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create the .got section to hold the global offset table. */
|
||||
|
||||
static boolean
|
||||
elf32_sparc_create_got_section (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
register asection *s;
|
||||
struct elf_link_hash_entry *h;
|
||||
|
||||
/* This function may be called more than once. */
|
||||
if (bfd_get_section_by_name (abfd, ".got") != NULL)
|
||||
return true;
|
||||
|
||||
s = bfd_make_section (abfd, ".got");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s,
|
||||
(SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
|
||||
| SEC_IN_MEMORY))
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
/* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
|
||||
section. We don't do this in the linker script because we don't
|
||||
want to define the symbol if we are not creating a global offset
|
||||
table. FIXME: The Solaris linker puts _GLOBAL_OFFSET_TABLE_ at
|
||||
the start of the .got section, but when using the small PIC model
|
||||
the .got is accessed using a signed 13 bit offset. Shouldn't
|
||||
_GLOBAL_OFFSET_TABLE_ be located at .got + 4096? */
|
||||
h = NULL;
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
|
||||
(const char *) NULL, false, get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return false;
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! bfd_elf32_link_record_dynamic_symbol (info, h))
|
||||
return false;
|
||||
|
||||
/* The first global offset table entry is reserved. */
|
||||
s->_raw_size += 4;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Look through the relocs for a section during the first phase, and
|
||||
allocate space in the global offset table or procedure linkage
|
||||
table. */
|
||||
@ -373,7 +251,7 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs)
|
||||
{
|
||||
/* Create the .got section. */
|
||||
elf_hash_table (info)->dynobj = dynobj = abfd;
|
||||
if (! elf32_sparc_create_got_section (dynobj, info))
|
||||
if (! _bfd_elf_create_got_section (dynobj, info))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -515,7 +393,7 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
name = (elf_string_from_elf_section
|
||||
name = (bfd_elf_string_from_elf_section
|
||||
(abfd,
|
||||
elf_elfheader (abfd)->e_shstrndx,
|
||||
elf_section_data (sec)->rel_hdr.sh_name));
|
||||
@ -1211,7 +1089,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
{
|
||||
const char *name;
|
||||
|
||||
name = (elf_string_from_elf_section
|
||||
name = (bfd_elf_string_from_elf_section
|
||||
(input_bfd,
|
||||
elf_elfheader (input_bfd)->e_shstrndx,
|
||||
elf_section_data (input_section)->rel_hdr.sh_name));
|
||||
@ -1308,9 +1186,9 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
name = h->root.root.string;
|
||||
else
|
||||
{
|
||||
name = elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
name = bfd_elf_string_from_elf_section (input_bfd,
|
||||
symtab_hdr->sh_link,
|
||||
sym->st_name);
|
||||
if (name == NULL)
|
||||
return false;
|
||||
if (*name == '\0')
|
||||
@ -1568,7 +1446,7 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
|
||||
sym.st_shndx = indx;
|
||||
|
||||
bfd_elf32_swap_symbol_out (output_bfd, &sym,
|
||||
((Elf32_External_Sym *) sdynsym->contents
|
||||
(char*) ((Elf32_External_Sym *) sdynsym->contents
|
||||
+ elf_section_data (s)->dynindx));
|
||||
}
|
||||
|
||||
@ -1587,7 +1465,7 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
|
||||
#define ELF_MACHINE_CODE EM_SPARC
|
||||
#define ELF_MAXPAGESIZE 0x10000
|
||||
#define elf_backend_create_dynamic_sections \
|
||||
elf32_sparc_create_dynamic_sections
|
||||
_bfd_elf_create_dynamic_sections
|
||||
#define elf_backend_check_relocs elf32_sparc_check_relocs
|
||||
#define elf_backend_adjust_dynamic_symbol \
|
||||
elf32_sparc_adjust_dynamic_symbol
|
||||
@ -1598,5 +1476,8 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info)
|
||||
elf32_sparc_finish_dynamic_symbol
|
||||
#define elf_backend_finish_dynamic_sections \
|
||||
elf32_sparc_finish_dynamic_sections
|
||||
#define elf_backend_want_got_plt 0
|
||||
#define elf_backend_plt_readonly 1
|
||||
#define elf_backend_want_plt_sym 1
|
||||
|
||||
#include "elf32-target.h"
|
||||
|
5814
bfd/elfcode.h
5814
bfd/elfcode.h
File diff suppressed because it is too large
Load Diff
466
bfd/elfcore.h
Normal file
466
bfd/elfcore.h
Normal file
@ -0,0 +1,466 @@
|
||||
/* Core file support */
|
||||
|
||||
#ifdef HAVE_PROCFS /* Some core file support requires host /proc files */
|
||||
#include <sys/procfs.h>
|
||||
#else
|
||||
#define bfd_prstatus(abfd, descdata, descsz, filepos) true
|
||||
#define bfd_fpregset(abfd, descdata, descsz, filepos) true
|
||||
#define bfd_prpsinfo(abfd, descdata, descsz, filepos) true
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PROCFS
|
||||
|
||||
static boolean
|
||||
bfd_prstatus (abfd, descdata, descsz, filepos)
|
||||
bfd *abfd;
|
||||
char *descdata;
|
||||
int descsz;
|
||||
long filepos;
|
||||
{
|
||||
asection *newsect;
|
||||
prstatus_t *status = (prstatus_t *) 0;
|
||||
|
||||
if (descsz == sizeof (prstatus_t))
|
||||
{
|
||||
newsect = bfd_make_section (abfd, ".reg");
|
||||
if (newsect == NULL)
|
||||
return false;
|
||||
newsect->_raw_size = sizeof (status->pr_reg);
|
||||
newsect->filepos = filepos + (long) &status->pr_reg;
|
||||
newsect->flags = SEC_HAS_CONTENTS;
|
||||
newsect->alignment_power = 2;
|
||||
if ((core_prstatus (abfd) = bfd_alloc (abfd, descsz)) != NULL)
|
||||
{
|
||||
memcpy (core_prstatus (abfd), descdata, descsz);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Stash a copy of the prpsinfo structure away for future use. */
|
||||
|
||||
static boolean
|
||||
bfd_prpsinfo (abfd, descdata, descsz, filepos)
|
||||
bfd *abfd;
|
||||
char *descdata;
|
||||
int descsz;
|
||||
long filepos;
|
||||
{
|
||||
if (descsz == sizeof (prpsinfo_t))
|
||||
{
|
||||
if ((core_prpsinfo (abfd) = bfd_alloc (abfd, descsz)) == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
memcpy (core_prpsinfo (abfd), descdata, descsz);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
bfd_fpregset (abfd, descdata, descsz, filepos)
|
||||
bfd *abfd;
|
||||
char *descdata;
|
||||
int descsz;
|
||||
long filepos;
|
||||
{
|
||||
asection *newsect;
|
||||
|
||||
newsect = bfd_make_section (abfd, ".reg2");
|
||||
if (newsect == NULL)
|
||||
return false;
|
||||
newsect->_raw_size = descsz;
|
||||
newsect->filepos = filepos;
|
||||
newsect->flags = SEC_HAS_CONTENTS;
|
||||
newsect->alignment_power = 2;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* HAVE_PROCFS */
|
||||
|
||||
/* Return a pointer to the args (including the command name) that were
|
||||
seen by the program that generated the core dump. Note that for
|
||||
some reason, a spurious space is tacked onto the end of the args
|
||||
in some (at least one anyway) implementations, so strip it off if
|
||||
it exists. */
|
||||
|
||||
char *
|
||||
elf_core_file_failing_command (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
#ifdef HAVE_PROCFS
|
||||
if (core_prpsinfo (abfd))
|
||||
{
|
||||
prpsinfo_t *p = core_prpsinfo (abfd);
|
||||
char *scan = p->pr_psargs;
|
||||
while (*scan++)
|
||||
{;
|
||||
}
|
||||
scan -= 2;
|
||||
if ((scan > p->pr_psargs) && (*scan == ' '))
|
||||
{
|
||||
*scan = '\000';
|
||||
}
|
||||
return p->pr_psargs;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return the number of the signal that caused the core dump. Presumably,
|
||||
since we have a core file, we got a signal of some kind, so don't bother
|
||||
checking the other process status fields, just return the signal number.
|
||||
*/
|
||||
|
||||
int
|
||||
elf_core_file_failing_signal (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
#ifdef HAVE_PROCFS
|
||||
if (core_prstatus (abfd))
|
||||
{
|
||||
return ((prstatus_t *) (core_prstatus (abfd)))->pr_cursig;
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check to see if the core file could reasonably be expected to have
|
||||
come for the current executable file. Note that by default we return
|
||||
true unless we find something that indicates that there might be a
|
||||
problem.
|
||||
*/
|
||||
|
||||
boolean
|
||||
elf_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
#ifdef HAVE_PROCFS
|
||||
char *corename;
|
||||
char *execname;
|
||||
#endif
|
||||
|
||||
/* First, xvecs must match since both are ELF files for the same target. */
|
||||
|
||||
if (core_bfd->xvec != exec_bfd->xvec)
|
||||
{
|
||||
bfd_set_error (bfd_error_system_call);
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PROCFS
|
||||
|
||||
/* If no prpsinfo, just return true. Otherwise, grab the last component
|
||||
of the exec'd pathname from the prpsinfo. */
|
||||
|
||||
if (core_prpsinfo (core_bfd))
|
||||
{
|
||||
corename = (((prpsinfo_t *) core_prpsinfo (core_bfd))->pr_fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Find the last component of the executable pathname. */
|
||||
|
||||
if ((execname = strrchr (exec_bfd->filename, '/')) != NULL)
|
||||
{
|
||||
execname++;
|
||||
}
|
||||
else
|
||||
{
|
||||
execname = (char *) exec_bfd->filename;
|
||||
}
|
||||
|
||||
/* See if they match */
|
||||
|
||||
return strcmp (execname, corename) ? false : true;
|
||||
|
||||
#else
|
||||
|
||||
return true;
|
||||
|
||||
#endif /* HAVE_PROCFS */
|
||||
}
|
||||
|
||||
/* ELF core files contain a segment of type PT_NOTE, that holds much of
|
||||
the information that would normally be available from the /proc interface
|
||||
for the process, at the time the process dumped core. Currently this
|
||||
includes copies of the prstatus, prpsinfo, and fpregset structures.
|
||||
|
||||
Since these structures are potentially machine dependent in size and
|
||||
ordering, bfd provides two levels of support for them. The first level,
|
||||
available on all machines since it does not require that the host
|
||||
have /proc support or the relevant include files, is to create a bfd
|
||||
section for each of the prstatus, prpsinfo, and fpregset structures,
|
||||
without any interpretation of their contents. With just this support,
|
||||
the bfd client will have to interpret the structures itself. Even with
|
||||
/proc support, it might want these full structures for it's own reasons.
|
||||
|
||||
In the second level of support, where HAVE_PROCFS is defined, bfd will
|
||||
pick apart the structures to gather some additional information that
|
||||
clients may want, such as the general register set, the name of the
|
||||
exec'ed file and its arguments, the signal (if any) that caused the
|
||||
core dump, etc.
|
||||
|
||||
*/
|
||||
|
||||
static boolean
|
||||
elf_corefile_note (abfd, hdr)
|
||||
bfd *abfd;
|
||||
Elf_Internal_Phdr *hdr;
|
||||
{
|
||||
Elf_External_Note *x_note_p; /* Elf note, external form */
|
||||
Elf_Internal_Note i_note; /* Elf note, internal form */
|
||||
char *buf = NULL; /* Entire note segment contents */
|
||||
char *namedata; /* Name portion of the note */
|
||||
char *descdata; /* Descriptor portion of the note */
|
||||
char *sectname; /* Name to use for new section */
|
||||
long filepos; /* File offset to descriptor data */
|
||||
asection *newsect;
|
||||
|
||||
if (hdr->p_filesz > 0
|
||||
&& (buf = (char *) malloc (hdr->p_filesz)) != NULL
|
||||
&& bfd_seek (abfd, hdr->p_offset, SEEK_SET) != -1
|
||||
&& bfd_read ((PTR) buf, hdr->p_filesz, 1, abfd) == hdr->p_filesz)
|
||||
{
|
||||
x_note_p = (Elf_External_Note *) buf;
|
||||
while ((char *) x_note_p < (buf + hdr->p_filesz))
|
||||
{
|
||||
i_note.namesz = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->namesz);
|
||||
i_note.descsz = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->descsz);
|
||||
i_note.type = bfd_h_get_32 (abfd, (bfd_byte *) x_note_p->type);
|
||||
namedata = x_note_p->name;
|
||||
descdata = namedata + BFD_ALIGN (i_note.namesz, 4);
|
||||
filepos = hdr->p_offset + (descdata - buf);
|
||||
switch (i_note.type)
|
||||
{
|
||||
case NT_PRSTATUS:
|
||||
/* process descdata as prstatus info */
|
||||
if (! bfd_prstatus (abfd, descdata, i_note.descsz, filepos))
|
||||
return false;
|
||||
sectname = ".prstatus";
|
||||
break;
|
||||
case NT_FPREGSET:
|
||||
/* process descdata as fpregset info */
|
||||
if (! bfd_fpregset (abfd, descdata, i_note.descsz, filepos))
|
||||
return false;
|
||||
sectname = ".fpregset";
|
||||
break;
|
||||
case NT_PRPSINFO:
|
||||
/* process descdata as prpsinfo */
|
||||
if (! bfd_prpsinfo (abfd, descdata, i_note.descsz, filepos))
|
||||
return false;
|
||||
sectname = ".prpsinfo";
|
||||
break;
|
||||
default:
|
||||
/* Unknown descriptor, just ignore it. */
|
||||
sectname = NULL;
|
||||
break;
|
||||
}
|
||||
if (sectname != NULL)
|
||||
{
|
||||
newsect = bfd_make_section (abfd, sectname);
|
||||
if (newsect == NULL)
|
||||
return false;
|
||||
newsect->_raw_size = i_note.descsz;
|
||||
newsect->filepos = filepos;
|
||||
newsect->flags = SEC_ALLOC | SEC_HAS_CONTENTS;
|
||||
newsect->alignment_power = 2;
|
||||
}
|
||||
x_note_p = (Elf_External_Note *)
|
||||
(descdata + BFD_ALIGN (i_note.descsz, 4));
|
||||
}
|
||||
}
|
||||
if (buf != NULL)
|
||||
{
|
||||
free (buf);
|
||||
}
|
||||
else if (hdr->p_filesz > 0)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/* Core files are simply standard ELF formatted files that partition
|
||||
the file using the execution view of the file (program header table)
|
||||
rather than the linking view. In fact, there is no section header
|
||||
table in a core file.
|
||||
|
||||
The process status information (including the contents of the general
|
||||
register set) and the floating point register set are stored in a
|
||||
segment of type PT_NOTE. We handcraft a couple of extra bfd sections
|
||||
that allow standard bfd access to the general registers (.reg) and the
|
||||
floating point registers (.reg2).
|
||||
|
||||
*/
|
||||
|
||||
const bfd_target *
|
||||
elf_core_file_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
|
||||
Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
|
||||
Elf_External_Phdr x_phdr; /* Program header table entry, external form */
|
||||
Elf_Internal_Phdr *i_phdrp; /* Program header table, internal form */
|
||||
unsigned int phindex;
|
||||
struct elf_backend_data *ebd;
|
||||
|
||||
/* Read in the ELF header in external format. */
|
||||
|
||||
if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
|
||||
{
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Now check to see if we have a valid ELF file, and one that BFD can
|
||||
make use of. The magic number must match, the address size ('class')
|
||||
and byte-swapping must match our XVEC entry, and it must have a
|
||||
program header table (FIXME: See comments re segments at top of this
|
||||
file). */
|
||||
|
||||
if (elf_file_p (&x_ehdr) == false)
|
||||
{
|
||||
wrong:
|
||||
bfd_set_error (bfd_error_wrong_format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* FIXME, Check EI_VERSION here ! */
|
||||
|
||||
{
|
||||
#if ARCH_SIZE == 32
|
||||
int desired_address_size = ELFCLASS32;
|
||||
#endif
|
||||
#if ARCH_SIZE == 64
|
||||
int desired_address_size = ELFCLASS64;
|
||||
#endif
|
||||
|
||||
if (x_ehdr.e_ident[EI_CLASS] != desired_address_size)
|
||||
goto wrong;
|
||||
}
|
||||
|
||||
/* Switch xvec to match the specified byte order. */
|
||||
switch (x_ehdr.e_ident[EI_DATA])
|
||||
{
|
||||
case ELFDATA2MSB: /* Big-endian */
|
||||
if (abfd->xvec->byteorder_big_p == false)
|
||||
goto wrong;
|
||||
break;
|
||||
case ELFDATA2LSB: /* Little-endian */
|
||||
if (abfd->xvec->byteorder_big_p == true)
|
||||
goto wrong;
|
||||
break;
|
||||
case ELFDATANONE: /* No data encoding specified */
|
||||
default: /* Unknown data encoding specified */
|
||||
goto wrong;
|
||||
}
|
||||
|
||||
/* Allocate an instance of the elf_obj_tdata structure and hook it up to
|
||||
the tdata pointer in the bfd. */
|
||||
|
||||
elf_tdata (abfd) =
|
||||
(struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
|
||||
if (elf_tdata (abfd) == NULL)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* FIXME, `wrong' returns from this point onward, leak memory. */
|
||||
|
||||
/* Now that we know the byte order, swap in the rest of the header */
|
||||
i_ehdrp = elf_elfheader (abfd);
|
||||
elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
|
||||
#if DEBUG & 1
|
||||
elf_debug_file (i_ehdrp);
|
||||
#endif
|
||||
|
||||
ebd = get_elf_backend_data (abfd);
|
||||
|
||||
/* Check that the ELF e_machine field matches what this particular
|
||||
BFD format expects. */
|
||||
if (ebd->elf_machine_code != i_ehdrp->e_machine
|
||||
&& (ebd->elf_machine_alt1 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
|
||||
&& (ebd->elf_machine_alt2 == 0 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
|
||||
{
|
||||
const bfd_target * const *target_ptr;
|
||||
|
||||
if (ebd->elf_machine_code != EM_NONE)
|
||||
goto wrong;
|
||||
|
||||
/* This is the generic ELF target. Let it match any ELF target
|
||||
for which we do not have a specific backend. */
|
||||
for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++)
|
||||
{
|
||||
struct elf_backend_data *back;
|
||||
|
||||
if ((*target_ptr)->flavour != bfd_target_elf_flavour)
|
||||
continue;
|
||||
back = (struct elf_backend_data *) (*target_ptr)->backend_data;
|
||||
if (back->elf_machine_code == i_ehdrp->e_machine)
|
||||
{
|
||||
/* target_ptr is an ELF backend which matches this
|
||||
object file, so reject the generic ELF target. */
|
||||
goto wrong;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If there is no program header, or the type is not a core file, then
|
||||
we are hosed. */
|
||||
if (i_ehdrp->e_phoff == 0 || i_ehdrp->e_type != ET_CORE)
|
||||
goto wrong;
|
||||
|
||||
/* Allocate space for a copy of the program header table in
|
||||
internal form, seek to the program header table in the file,
|
||||
read it in, and convert it to internal form. As a simple sanity
|
||||
check, verify that the what BFD thinks is the size of each program
|
||||
header table entry actually matches the size recorded in the file. */
|
||||
|
||||
if (i_ehdrp->e_phentsize != sizeof (x_phdr))
|
||||
goto wrong;
|
||||
i_phdrp = (Elf_Internal_Phdr *)
|
||||
bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
|
||||
if (!i_phdrp)
|
||||
{
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return NULL;
|
||||
}
|
||||
if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) == -1)
|
||||
return NULL;
|
||||
for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
|
||||
{
|
||||
if (bfd_read ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd)
|
||||
!= sizeof (x_phdr))
|
||||
return NULL;
|
||||
elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex);
|
||||
}
|
||||
|
||||
/* Once all of the program headers have been read and converted, we
|
||||
can start processing them. */
|
||||
|
||||
for (phindex = 0; phindex < i_ehdrp->e_phnum; phindex++)
|
||||
{
|
||||
bfd_section_from_phdr (abfd, i_phdrp + phindex, phindex);
|
||||
if ((i_phdrp + phindex)->p_type == PT_NOTE)
|
||||
{
|
||||
if (! elf_corefile_note (abfd, i_phdrp + phindex))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remember the entry point specified in the ELF file header. */
|
||||
|
||||
bfd_get_start_address (abfd) = i_ehdrp->e_entry;
|
||||
|
||||
return abfd->xvec;
|
||||
}
|
204
bfd/elflink.c
Normal file
204
bfd/elflink.c
Normal file
@ -0,0 +1,204 @@
|
||||
/* ELF linking support for BFD.
|
||||
Copyright 1993, 1995 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
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. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "bfdlink.h"
|
||||
#include "libbfd.h"
|
||||
#define ARCH_SIZE 0
|
||||
#include "libelf.h"
|
||||
|
||||
boolean
|
||||
_bfd_elf_create_got_section (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
struct elf_link_hash_entry *h;
|
||||
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
|
||||
/* This function may be called more than once. */
|
||||
if (bfd_get_section_by_name (abfd, ".got") != NULL)
|
||||
return true;
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".got");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (bed->want_got_plt)
|
||||
{
|
||||
s = bfd_make_section (abfd, ".got.plt");
|
||||
if (s == NULL
|
||||
|| !bfd_set_section_flags (abfd, s, flags)
|
||||
|| !bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
|
||||
(or .got.plt) section. We don't do this in the linker script
|
||||
because we don't want to define the symbol if we are not creating
|
||||
a global offset table. */
|
||||
h = NULL;
|
||||
if (!(_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0,
|
||||
(const char *) NULL, false, get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return false;
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! _bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return false;
|
||||
|
||||
/* The first three global offset table entries are reserved. */
|
||||
s->_raw_size += 3 * 4;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Create dynamic sections when linking against a dynamic object. */
|
||||
|
||||
boolean
|
||||
_bfd_elf_create_dynamic_sections (abfd, info)
|
||||
bfd *abfd;
|
||||
struct bfd_link_info *info;
|
||||
{
|
||||
flagword flags;
|
||||
register asection *s;
|
||||
struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
|
||||
/* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
|
||||
.rel[a].bss sections. */
|
||||
|
||||
flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
|
||||
|
||||
s = bfd_make_section (abfd, ".plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s,
|
||||
(flags | SEC_CODE
|
||||
| (bed->plt_readonly ? SEC_READONLY : 0)))
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (bed->want_plt_sym)
|
||||
{
|
||||
/* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
||||
.plt section. */
|
||||
struct elf_link_hash_entry *h = NULL;
|
||||
if (! (_bfd_generic_link_add_one_symbol
|
||||
(info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
|
||||
(bfd_vma) 0, (const char *) NULL, false,
|
||||
get_elf_backend_data (abfd)->collect,
|
||||
(struct bfd_link_hash_entry **) &h)))
|
||||
return false;
|
||||
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
||||
h->type = STT_OBJECT;
|
||||
|
||||
if (info->shared
|
||||
&& ! _bfd_elf_link_record_dynamic_symbol (info, h))
|
||||
return false;
|
||||
}
|
||||
|
||||
s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.plt" : ".rel.plt");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
|
||||
if (! _bfd_elf_create_got_section (abfd, info))
|
||||
return false;
|
||||
|
||||
/* The .dynbss section is a place to put symbols which are defined
|
||||
by dynamic objects, are referenced by regular objects, and are
|
||||
not functions. We must allocate space for them in the process
|
||||
image and use a R_*_COPY reloc to tell the dynamic linker to
|
||||
initialize them at run time. The linker script puts the .dynbss
|
||||
section into the .bss section of the final image. */
|
||||
s = bfd_make_section (abfd, ".dynbss");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
|
||||
return false;
|
||||
|
||||
/* The .rel[a].bss section holds copy relocs. This section is not
|
||||
normally needed. We need to create it here, though, so that the
|
||||
linker will map it to an output section. We can't just create it
|
||||
only if we need it, because we will not know whether we need it
|
||||
until we have seen all the input files, and the first time the
|
||||
main linker code calls BFD after examining all the input files
|
||||
(size_dynamic_sections) the input sections have already been
|
||||
mapped to the output sections. If the section turns out not to
|
||||
be needed, we can discard it later. We will never need this
|
||||
section when generating a shared object, since they do not use
|
||||
copy relocs. */
|
||||
if (! info->shared)
|
||||
{
|
||||
s = bfd_make_section (abfd, bed->use_rela_p ? ".rela.bss" : ".rel.bss");
|
||||
if (s == NULL
|
||||
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
||||
|| ! bfd_set_section_alignment (abfd, s, 2))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Record a new dynamic symbol. We record the dynamic symbols as we
|
||||
read the input files, since we need to have a list of all of them
|
||||
before we can determine the final sizes of the output sections.
|
||||
Note that we may actually call this function even though we are not
|
||||
going to output any dynamic symbols; in some cases we know that a
|
||||
symbol should be in the dynamic symbol table, but only if there is
|
||||
one. */
|
||||
|
||||
boolean
|
||||
_bfd_elf_link_record_dynamic_symbol (info, h)
|
||||
struct bfd_link_info *info;
|
||||
struct elf_link_hash_entry *h;
|
||||
{
|
||||
if (h->dynindx == -1)
|
||||
{
|
||||
struct bfd_strtab_hash *dynstr;
|
||||
|
||||
h->dynindx = elf_hash_table (info)->dynsymcount;
|
||||
++elf_hash_table (info)->dynsymcount;
|
||||
|
||||
dynstr = elf_hash_table (info)->dynstr;
|
||||
if (dynstr == NULL)
|
||||
{
|
||||
/* Create a strtab to hold the dynamic symbol names. */
|
||||
elf_hash_table (info)->dynstr = dynstr = _bfd_elf_stringtab_init ();
|
||||
if (dynstr == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
h->dynstr_index = ((unsigned long)
|
||||
_bfd_stringtab_add (dynstr, h->root.root.string,
|
||||
true, false));
|
||||
if (h->dynstr_index == (unsigned long) -1)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
3018
bfd/elflink.h
Normal file
3018
bfd/elflink.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,39 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#define bfd_elfNN_get_section_contents _bfd_generic_get_section_contents
|
||||
#endif
|
||||
|
||||
#define bfd_elfNN_canonicalize_dynamic_symtab _bfd_elf_canonicalize_dynamic_symtab
|
||||
#define bfd_elfNN_canonicalize_reloc _bfd_elf_canonicalize_reloc
|
||||
#ifndef bfd_elfNN_find_nearest_line
|
||||
#define bfd_elfNN_find_nearest_line _bfd_elf_find_nearest_line
|
||||
#endif
|
||||
#define bfd_elfNN_get_dynamic_symtab_upper_bound _bfd_elf_get_dynamic_symtab_upper_bound
|
||||
#define bfd_elfNN_get_lineno _bfd_elf_get_lineno
|
||||
#define bfd_elfNN_get_reloc_upper_bound _bfd_elf_get_reloc_upper_bound
|
||||
#define bfd_elfNN_get_symbol_info _bfd_elf_get_symbol_info
|
||||
#define bfd_elfNN_get_symtab _bfd_elf_get_symtab
|
||||
#define bfd_elfNN_get_symtab_upper_bound _bfd_elf_get_symtab_upper_bound
|
||||
#if 0 /* done in libelf.h */
|
||||
#define bfd_elfNN_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
|
||||
#endif
|
||||
#define bfd_elfNN_make_empty_symbol _bfd_elf_make_empty_symbol
|
||||
#define bfd_elfNN_new_section_hook _bfd_elf_new_section_hook
|
||||
#define bfd_elfNN_set_arch_mach _bfd_elf_set_arch_mach
|
||||
#ifndef bfd_elfNN_set_section_contents
|
||||
#define bfd_elfNN_set_section_contents _bfd_elf_set_section_contents
|
||||
#endif
|
||||
#define bfd_elfNN_sizeof_headers _bfd_elf_sizeof_headers
|
||||
#define bfd_elfNN_write_object_contents _bfd_elf_write_object_contents
|
||||
|
||||
#ifndef elf_backend_want_got_plt
|
||||
#define elf_backend_want_got_plt 0
|
||||
#endif
|
||||
#ifndef elf_backend_plt_readonly
|
||||
#define elf_backend_plt_readonly 0
|
||||
#endif
|
||||
#ifndef elf_backend_want_plt_sym
|
||||
#define elf_backend_want_plt_sym 0
|
||||
#endif
|
||||
|
||||
#define bfd_elfNN_bfd_debug_info_start bfd_void
|
||||
#define bfd_elfNN_bfd_debug_info_end bfd_void
|
||||
#define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
|
||||
@ -179,6 +212,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#define ELF_MACHINE_ALT2 0
|
||||
#endif
|
||||
|
||||
extern const struct elf_size_info _bfd_elfNN_size_info;
|
||||
|
||||
static CONST struct elf_backend_data elfNN_bed =
|
||||
{
|
||||
#ifdef USE_REL
|
||||
@ -213,7 +248,11 @@ static CONST struct elf_backend_data elfNN_bed =
|
||||
elf_backend_final_write_processing,
|
||||
elf_backend_ecoff_debug_swap,
|
||||
ELF_MACHINE_ALT1,
|
||||
ELF_MACHINE_ALT2
|
||||
ELF_MACHINE_ALT2,
|
||||
&_bfd_elfNN_size_info,
|
||||
elf_backend_want_got_plt,
|
||||
elf_backend_plt_readonly,
|
||||
elf_backend_want_plt_sym,
|
||||
};
|
||||
|
||||
#ifdef TARGET_BIG_SYM
|
||||
|
144
bfd/libelf.h
144
bfd/libelf.h
@ -170,6 +170,26 @@ struct elf_link_hash_table
|
||||
|
||||
/* Constant information held for an ELF backend. */
|
||||
|
||||
struct elf_size_info {
|
||||
unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
|
||||
unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
|
||||
|
||||
unsigned char arch_size, file_align;
|
||||
unsigned char elfclass, ev_current;
|
||||
int (*write_out_phdrs) PARAMS ((bfd *, Elf_Internal_Phdr *, int));
|
||||
boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
|
||||
void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
|
||||
void (*swap_symbol_out) PARAMS ((bfd *, Elf_Internal_Sym *, char *));
|
||||
boolean (*slurp_reloc_table) PARAMS ((bfd *, asection *, asymbol **));
|
||||
long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
|
||||
};
|
||||
|
||||
#define elf_symbol_from(ABFD,S) \
|
||||
(((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
|
||||
&& (S)->the_bfd->tdata.elf_obj_data != 0) \
|
||||
? (elf_symbol_type *) (S) \
|
||||
: 0)
|
||||
|
||||
struct elf_backend_data
|
||||
{
|
||||
/* Whether the backend uses REL or RELA relocations. FIXME: some
|
||||
@ -399,6 +419,12 @@ struct elf_backend_data
|
||||
/* Alternate EM_xxxx machine codes for this backend. */
|
||||
int elf_machine_alt1;
|
||||
int elf_machine_alt2;
|
||||
|
||||
const struct elf_size_info *s;
|
||||
|
||||
unsigned char want_got_plt : 1;
|
||||
unsigned char plt_readonly : 1;
|
||||
unsigned char want_plt_sym : 1;
|
||||
};
|
||||
|
||||
/* Information stored for each BFD section in an ELF file. This
|
||||
@ -516,11 +542,13 @@ struct elf_obj_tdata
|
||||
#define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
|
||||
#define elf_ppc_flags_init(bfd) (elf_tdata(bfd) -> ppc_flags_init)
|
||||
|
||||
extern char * elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned));
|
||||
extern char * elf_get_str_section PARAMS ((bfd *, unsigned));
|
||||
extern char * bfd_elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned));
|
||||
extern char * bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
|
||||
|
||||
extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
|
||||
bfd_print_symbol_type));
|
||||
#define elf_string_from_elf_strtab(abfd,strindex) \
|
||||
bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
|
||||
|
||||
#define bfd_elf32_print_symbol bfd_elf_print_symbol
|
||||
#define bfd_elf64_print_symbol bfd_elf_print_symbol
|
||||
@ -551,8 +579,54 @@ extern boolean _bfd_elf_link_hash_table_init
|
||||
struct bfd_hash_table *,
|
||||
const char *)));
|
||||
|
||||
extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *));
|
||||
extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *));
|
||||
extern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
|
||||
extern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
|
||||
file_ptr,
|
||||
bfd_size_type));
|
||||
extern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
|
||||
extern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
|
||||
extern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
|
||||
extern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
|
||||
extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
|
||||
extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
|
||||
arelent **, asymbol **));
|
||||
extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
|
||||
extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
|
||||
symbol_info *));
|
||||
extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
|
||||
extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
|
||||
unsigned long));
|
||||
extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
|
||||
asymbol **,
|
||||
bfd_vma, CONST char **,
|
||||
CONST char **,
|
||||
unsigned int *));
|
||||
extern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
|
||||
extern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
|
||||
|
||||
/* If the target doesn't have reloc handling written yet: */
|
||||
extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
|
||||
Elf_Internal_Rela *));
|
||||
|
||||
asection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
|
||||
boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
|
||||
struct bfd_link_info *));
|
||||
struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
|
||||
boolean
|
||||
_bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
|
||||
struct elf_link_hash_entry *));
|
||||
boolean
|
||||
_bfd_elf_compute_section_file_positions PARAMS ((bfd *,
|
||||
struct bfd_link_info *));
|
||||
void _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
|
||||
file_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
|
||||
file_ptr,
|
||||
boolean));
|
||||
|
||||
boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
|
||||
struct bfd_link_info *));
|
||||
boolean _bfd_elf_create_got_section PARAMS ((bfd *,
|
||||
struct bfd_link_info *));
|
||||
|
||||
extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
|
||||
extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
|
||||
@ -560,30 +634,7 @@ extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
|
||||
extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
|
||||
extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
|
||||
bfd *));
|
||||
extern boolean bfd_elf32_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
|
||||
file_ptr,
|
||||
bfd_size_type));
|
||||
|
||||
extern long bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *));
|
||||
extern long bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **));
|
||||
extern long bfd_elf32_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
|
||||
extern long bfd_elf32_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
|
||||
extern long bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
|
||||
extern long bfd_elf32_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
|
||||
arelent **, asymbol **));
|
||||
extern asymbol *bfd_elf32_make_empty_symbol PARAMS ((bfd *));
|
||||
extern void bfd_elf32_get_symbol_info PARAMS ((bfd *, asymbol *,
|
||||
symbol_info *));
|
||||
extern alent *bfd_elf32_get_lineno PARAMS ((bfd *, asymbol *));
|
||||
extern boolean bfd_elf32_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
|
||||
unsigned long));
|
||||
extern boolean bfd_elf32_find_nearest_line PARAMS ((bfd *, asection *,
|
||||
asymbol **,
|
||||
bfd_vma, CONST char **,
|
||||
CONST char **,
|
||||
unsigned int *));
|
||||
extern int bfd_elf32_sizeof_headers PARAMS ((bfd *, boolean));
|
||||
extern boolean bfd_elf32_new_section_hook PARAMS ((bfd *, asection *));
|
||||
extern boolean bfd_elf32_bfd_link_add_symbols
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean bfd_elf32_bfd_final_link
|
||||
@ -592,7 +643,7 @@ extern boolean bfd_elf32_bfd_final_link
|
||||
extern void bfd_elf32_swap_symbol_in
|
||||
PARAMS ((bfd *, Elf32_External_Sym *, Elf_Internal_Sym *));
|
||||
extern void bfd_elf32_swap_symbol_out
|
||||
PARAMS ((bfd *, Elf_Internal_Sym *, Elf32_External_Sym *));
|
||||
PARAMS ((bfd *, Elf_Internal_Sym *, char *));
|
||||
extern void bfd_elf32_swap_reloc_in
|
||||
PARAMS ((bfd *, Elf32_External_Rel *, Elf_Internal_Rel *));
|
||||
extern void bfd_elf32_swap_reloc_out
|
||||
@ -609,12 +660,6 @@ extern boolean bfd_elf32_add_dynamic_entry
|
||||
PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
|
||||
extern boolean bfd_elf32_link_create_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean bfd_elf32_link_record_dynamic_symbol
|
||||
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
|
||||
|
||||
/* If the target doesn't have reloc handling written yet: */
|
||||
extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *,
|
||||
Elf32_Internal_Rela *));
|
||||
|
||||
extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
|
||||
extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
|
||||
@ -622,30 +667,6 @@ extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
|
||||
extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
|
||||
extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
|
||||
bfd *));
|
||||
extern boolean bfd_elf64_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
|
||||
file_ptr,
|
||||
bfd_size_type));
|
||||
|
||||
extern long bfd_elf64_get_symtab_upper_bound PARAMS ((bfd *));
|
||||
extern long bfd_elf64_get_symtab PARAMS ((bfd *, asymbol **));
|
||||
extern long bfd_elf64_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
|
||||
extern long bfd_elf64_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
|
||||
extern long bfd_elf64_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
|
||||
extern long bfd_elf64_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
|
||||
arelent **, asymbol **));
|
||||
extern asymbol *bfd_elf64_make_empty_symbol PARAMS ((bfd *));
|
||||
extern void bfd_elf64_get_symbol_info PARAMS ((bfd *, asymbol *,
|
||||
symbol_info *));
|
||||
extern alent *bfd_elf64_get_lineno PARAMS ((bfd *, asymbol *));
|
||||
extern boolean bfd_elf64_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
|
||||
unsigned long));
|
||||
extern boolean bfd_elf64_find_nearest_line PARAMS ((bfd *, asection *,
|
||||
asymbol **,
|
||||
bfd_vma, CONST char **,
|
||||
CONST char **,
|
||||
unsigned int *));
|
||||
extern int bfd_elf64_sizeof_headers PARAMS ((bfd *, boolean));
|
||||
extern boolean bfd_elf64_new_section_hook PARAMS ((bfd *, asection *));
|
||||
extern boolean bfd_elf64_bfd_link_add_symbols
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean bfd_elf64_bfd_final_link
|
||||
@ -671,11 +692,8 @@ extern boolean bfd_elf64_add_dynamic_entry
|
||||
PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
|
||||
extern boolean bfd_elf64_link_create_dynamic_sections
|
||||
PARAMS ((bfd *, struct bfd_link_info *));
|
||||
extern boolean bfd_elf64_link_record_dynamic_symbol
|
||||
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
|
||||
|
||||
/* If the target doesn't have reloc handling written yet: */
|
||||
extern void bfd_elf64_no_info_to_howto PARAMS ((bfd *, arelent *,
|
||||
Elf64_Internal_Rela *));
|
||||
#define bfd_elf32_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
|
||||
#define bfd_elf64_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
|
||||
|
||||
#endif /* _LIBELF_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user