* elf.c, elfcode.h, libelf.h: Serious reorganization.

Deleted `thunk' structure, merged into tdata, duplicate data eliminated.
Rearranged functions, grouping by function.
Broke up many functions in elfcode.h, re-ordered many parts of file writing
to handle unpredictable state of section relocation table as provided by
various applications.
Still needs cleanup: Merge functions back together, split out data structure
with only data that is used only when writing out object file.

* elf.c (bfd_elf_generic_reloc): New function, taken from coff-mips.c.
* elf32-sparc.c (elf_sparc_howto_table): Use it, to work around
bfd_perform_relocation lossage.
This commit is contained in:
Ken Raeburn 1993-07-19 19:12:59 +00:00
parent da374d8043
commit 32090b8e4f
7 changed files with 3091 additions and 2571 deletions

View File

@ -1,3 +1,25 @@
Mon Jul 19 14:53:30 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
* elf.c, elfcode.h, libelf.h: Serious reorganization.
Deleted `thunk' structure, merged into tdata, duplicate data
eliminated.
Rearranged functions, grouping by function.
Broke up many functions in elfcode.h, re-ordered many parts of
file writing to handle unpredictable state of section relocation
table as provided by various applications.
Still needs cleanup: Merge functions back together, split out
data structure with only data that is used only when writing out
object file.
* elf.c (bfd_elf_generic_reloc): New function, taken from
coff-mips.c.
* elf32-sparc.c (elf_sparc_howto_table): Use it, to work around
bfd_perform_relocation lossage.
* Makefile.in (BFD_LIBS): Include coff-mips.o and coff-msym.o, so
that gdb will link.
(ofiles): Don't use sort or uniq; do it with sh constructs.
Sun Jul 18 19:42:14 1993 Jim Kingdon (kingdon@rtl.cygnus.com)
* coffcode.h: Recognize I386PTXMAGIC.

242
bfd/elf.c Normal file
View File

@ -0,0 +1,242 @@
/* ELF executable support for BFD.
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"
#define ARCH_SIZE 0
#include "libelf.h"
#ifndef INLINE
#if __GNUC__ >= 2
#define INLINE __inline__
#else
#define INLINE
#endif
#endif
/* Standard ELF hash function. Do not change this function; you will
cause invalid hash tables to be generated. (Well, you would if this
were being used yet.) */
unsigned long
DEFUN (bfd_elf_hash, (name),
CONST unsigned char *name)
{
unsigned long h = 0;
unsigned long g;
int ch;
while ((ch = *name++) != '\0')
{
h = (h << 4) + ch;
if ((g = (h & 0xf0000000)) != 0)
{
h ^= g >> 24;
h &= ~g;
}
}
return h;
}
/* Read a specified number of bytes at a specified offset in an ELF
file, into a newly allocated buffer, and return a pointer to the
buffer. */
static char *
DEFUN (elf_read, (abfd, offset, size),
bfd * abfd AND
long offset AND
int size)
{
char *buf;
if ((buf = bfd_alloc (abfd, size)) == NULL)
{
bfd_error = no_memory;
return NULL;
}
if (bfd_seek (abfd, offset, SEEK_SET) == -1)
{
bfd_error = system_call_error;
return NULL;
}
if (bfd_read ((PTR) buf, size, 1, abfd) != size)
{
bfd_error = system_call_error;
return NULL;
}
return buf;
}
boolean
DEFUN (elf_mkobject, (abfd), bfd * abfd)
{
/* this just does initialization */
/* coff_mkobject zalloc's space for tdata.coff_obj_data ... */
elf_tdata (abfd) = (struct elf_obj_tdata *)
bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
if (elf_tdata (abfd) == 0)
{
bfd_error = no_memory;
return false;
}
/* since everything is done at close time, do we need any
initialization? */
return true;
}
char *
DEFUN (elf_get_str_section, (abfd, shindex),
bfd * abfd AND
unsigned int shindex)
{
Elf_Internal_Shdr **i_shdrp;
char *shstrtab = NULL;
unsigned int offset;
unsigned int shstrtabsize;
i_shdrp = elf_elfsections (abfd);
if (i_shdrp == 0 || i_shdrp[shindex] == 0)
return 0;
shstrtab = i_shdrp[shindex]->rawdata;
if (shstrtab == NULL)
{
/* No cached one, attempt to read, and cache what we read. */
offset = i_shdrp[shindex]->sh_offset;
shstrtabsize = i_shdrp[shindex]->sh_size;
shstrtab = elf_read (abfd, offset, shstrtabsize);
i_shdrp[shindex]->rawdata = (void *) shstrtab;
}
return shstrtab;
}
char *
DEFUN (elf_string_from_elf_section, (abfd, shindex, strindex),
bfd * abfd AND
unsigned int shindex AND
unsigned int strindex)
{
Elf_Internal_Shdr *hdr;
if (strindex == 0)
return "";
hdr = elf_elfsections (abfd)[shindex];
if (!hdr->rawdata
&& elf_get_str_section (abfd, shindex) == NULL)
return NULL;
return ((char *) hdr->rawdata) + strindex;
}
/*
INTERNAL_FUNCTION
bfd_elf_find_section
SYNOPSIS
struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
DESCRIPTION
Helper functions for GDB to locate the string tables.
Since BFD hides string tables from callers, GDB needs to use an
internal hook to find them. Sun's .stabstr, in particular,
isn't even pointed to by the .stab section, so ordinary
mechanisms wouldn't work to find it, even if we had some.
*/
struct elf_internal_shdr *
DEFUN (bfd_elf_find_section, (abfd, name),
bfd * abfd AND
char *name)
{
Elf_Internal_Shdr **i_shdrp;
char *shstrtab;
unsigned int max;
unsigned int i;
i_shdrp = elf_elfsections (abfd);
if (i_shdrp != NULL)
{
shstrtab = elf_get_str_section (abfd, elf_elfheader (abfd)->e_shstrndx);
if (shstrtab != NULL)
{
max = elf_elfheader (abfd)->e_shnum;
for (i = 1; i < max; i++)
if (!strcmp (&shstrtab[i_shdrp[i]->sh_name], name))
return i_shdrp[i];
}
}
return 0;
}
const struct bfd_elf_arch_map bfd_elf_arch_map[] = {
{ bfd_arch_sparc, EM_SPARC },
{ bfd_arch_i386, EM_386 },
{ bfd_arch_m68k, EM_68K },
{ bfd_arch_m88k, EM_88K },
{ bfd_arch_i860, EM_860 },
{ bfd_arch_mips, EM_MIPS },
{ bfd_arch_hppa, EM_HPPA },
};
const int bfd_elf_arch_map_size = sizeof (bfd_elf_arch_map) / sizeof (bfd_elf_arch_map[0]);
const char *const bfd_elf_section_type_names[] = {
"SHT_NULL", "SHT_PROGBITS", "SHT_SYMTAB", "SHT_STRTAB",
"SHT_RELA", "SHT_HASH", "SHT_DYNAMIC", "SHT_NOTE",
"SHT_NOBITS", "SHT_REL", "SHT_SHLIB", "SHT_DYNSYM",
};
/* 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. */
bfd_reloc_status_type
bfd_elf_generic_reloc (abfd,
reloc_entry,
symbol,
data,
input_section,
output_bfd)
bfd *abfd;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
{
if (output_bfd != (bfd *) NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0
&& reloc_entry->addend == 0)
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
return bfd_reloc_continue;
}

151
bfd/elf32-sparc.c Normal file
View File

@ -0,0 +1,151 @@
/* SPARC-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"
enum reloc_type
{
R_SPARC_NONE = 0,
R_SPARC_8, R_SPARC_16, R_SPARC_32,
R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
R_SPARC_WDISP30, R_SPARC_WDISP22,
R_SPARC_HI22, R_SPARC_22,
R_SPARC_13, R_SPARC_LO10,
R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
R_SPARC_PC10, R_SPARC_PC22,
R_SPARC_WPLT30,
R_SPARC_COPY,
R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
R_SPARC_RELATIVE,
R_SPARC_UA32,
R_SPARC_max
};
#if 0
static CONST char *CONST reloc_type_names[] =
{
"R_SPARC_NONE",
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
"R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
"R_SPARC_WDISP30", "R_SPARC_WDISP22",
"R_SPARC_HI22", "R_SPARC_22",
"R_SPARC_13", "R_SPARC_LO10",
"R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
"R_SPARC_PC10", "R_SPARC_PC22",
"R_SPARC_WPLT30",
"R_SPARC_COPY",
"R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
"R_SPARC_RELATIVE",
"R_SPARC_UA32",
};
#endif
static reloc_howto_type elf_sparc_howto_table[] =
{
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,false,false, &bfd_elf_generic_reloc,"R_SPARC_NONE", false,0,0x00000000,false),
HOWTO(R_SPARC_8, 0,0, 8,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_8", false,0,0x000000ff,false),
HOWTO(R_SPARC_16, 0,1,16,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_16", false,0,0x0000ffff,false),
HOWTO(R_SPARC_32, 0,2,32,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_32", false,0,0xffffffff,false),
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_DISP8", false,0,0x000000ff,false),
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_DISP16", false,0,0x0000ffff,false),
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_DISP32", false,0,0x00ffffff,false),
HOWTO(R_SPARC_WDISP30,2,2,30,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_WDISP30",false,0,0x3fffffff,false),
HOWTO(R_SPARC_WDISP22,2,2,22,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_WDISP22",false,0,0x003fffff,false),
HOWTO(R_SPARC_HI22, 10,2,22,false,0,true, false, &bfd_elf_generic_reloc,"R_SPARC_HI22", false,0,0x003fffff,false),
HOWTO(R_SPARC_22, 0,2,22,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_22", false,0,0x003fffff,false),
HOWTO(R_SPARC_13, 0,1,13,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_13", false,0,0x00001fff,false),
HOWTO(R_SPARC_LO10, 0,1,10,false,0,true, false, &bfd_elf_generic_reloc,"R_SPARC_LO10", false,0,0x000003ff,false),
HOWTO(R_SPARC_GOT10, 0,1,10,false,0,false, true, &bfd_elf_generic_reloc,"R_SPARC_GOT10", false,0,0x000003ff,false),
HOWTO(R_SPARC_GOT13, 0,1,13,false,0,false, true, &bfd_elf_generic_reloc,"R_SPARC_GOT13", false,0,0x00001fff,false),
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,false, true, &bfd_elf_generic_reloc,"R_SPARC_GOT22", false,0,0x003fffff,false),
HOWTO(R_SPARC_PC10, 0,1,10,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_PC10", false,0,0x000003ff,false),
HOWTO(R_SPARC_PC22, 0,2,22,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_PC22", false,0,0x003fffff,false),
HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,false,false, &bfd_elf_generic_reloc,"R_SPARC_WPLT30", false,0,0x00000000,false),
HOWTO(R_SPARC_COPY, 0,0,00,false,0,false,false, &bfd_elf_generic_reloc,"R_SPARC_COPY", false,0,0x00000000,false),
HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,false),
HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_JMP_SLOT",false,0,0x00000000,false),
HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_RELATIVE",false,0,0x00000000,false),
HOWTO(R_SPARC_UA32, 0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_UA32", false,0,0x00000000,false),
};
struct elf_reloc_map {
unsigned char bfd_reloc_val;
unsigned char elf_reloc_val;
};
static CONST struct elf_reloc_map sparc_reloc_map[] =
{
{ BFD_RELOC_NONE, R_SPARC_NONE, },
{ BFD_RELOC_16, R_SPARC_16, },
{ BFD_RELOC_8, R_SPARC_8 },
{ BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
{ BFD_RELOC_CTOR, R_SPARC_32 }, /* @@ Assumes 32 bits. */
{ BFD_RELOC_32, R_SPARC_32 },
{ BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
{ BFD_RELOC_HI22, R_SPARC_HI22 },
{ BFD_RELOC_LO10, R_SPARC_LO10, },
{ BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
{ BFD_RELOC_SPARC22, R_SPARC_22 },
{ BFD_RELOC_SPARC13, R_SPARC_13 },
{ BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
{ BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
{ BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
{ BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
{ BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
{ BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
{ BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
{ BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
{ BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
{ BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
{ BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
/* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
};
static CONST struct reloc_howto_struct *
DEFUN (bfd_elf32_bfd_reloc_type_lookup, (abfd, code),
bfd *abfd AND
bfd_reloc_code_real_type code)
{
int i;
for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
{
if (sparc_reloc_map[i].bfd_reloc_val == code)
return &elf_sparc_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
}
return 0;
}
static void
DEFUN (elf_info_to_howto, (abfd, cache_ptr, dst),
bfd *abfd AND
arelent *cache_ptr AND
Elf32_Internal_Rela *dst)
{
BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_SPARC_max);
cache_ptr->howto = &elf_sparc_howto_table[ELF32_R_TYPE(dst->r_info)];
}
#define TARGET_BIG_SYM bfd_elf32_sparc_vec
#define TARGET_BIG_NAME "elf32-sparc"
#define ELF_ARCH bfd_arch_sparc
#include "elf32-target.h"

View File

@ -66,6 +66,7 @@ static CONST struct elf_backend_data elf32_bed =
#else
0, /* elf_info_to_howto_rel */
#endif
bfd_elf32__write_relocs, /* write_relocs */
};
#ifdef TARGET_BIG_SYM

View File

@ -78,44 +78,44 @@ extern void abort ();
static reloc_howto_type elf_sparc_howto_table[] =
{
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,false,false, 0,"R_SPARC_NONE", false,0,0x00000000,false),
HOWTO(R_SPARC_8, 0,0, 8,false,0,true, true, 0,"R_SPARC_8", false,0,0x000000ff,false),
HOWTO(R_SPARC_16, 0,1,16,false,0,true, true, 0,"R_SPARC_16", false,0,0x0000ffff,false),
HOWTO(R_SPARC_32, 0,2,32,false,0,true, true, 0,"R_SPARC_32", false,0,0xffffffff,false),
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,false, true, 0,"R_SPARC_DISP8", false,0,0x000000ff,false),
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,false, true, 0,"R_SPARC_DISP16", false,0,0x0000ffff,false),
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,false, true, 0,"R_SPARC_DISP32", false,0,0x00ffffff,false),
HOWTO(R_SPARC_WDISP30,2,2,30,true, 0,false, true, 0,"R_SPARC_WDISP30",false,0,0x3fffffff,false),
HOWTO(R_SPARC_WDISP22,2,2,22,true, 0,false, true, 0,"R_SPARC_WDISP22",false,0,0x003fffff,false),
HOWTO(R_SPARC_HI22, 10,2,22,false,0,true, false, 0,"R_SPARC_HI22", false,0,0x003fffff,false),
HOWTO(R_SPARC_22, 0,2,22,false,0,true, true, 0,"R_SPARC_22", false,0,0x003fffff,false),
HOWTO(R_SPARC_13, 0,1,13,false,0,true, true, 0,"R_SPARC_13", false,0,0x00001fff,false),
HOWTO(R_SPARC_LO10, 0,1,10,false,0,true, false, 0,"R_SPARC_LO10", false,0,0x000003ff,false),
HOWTO(R_SPARC_GOT10, 0,1,10,false,0,false, true, 0,"R_SPARC_GOT10", false,0,0x000003ff,false),
HOWTO(R_SPARC_GOT13, 0,1,13,false,0,false, true, 0,"R_SPARC_GOT13", false,0,0x00001fff,false),
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,false, true, 0,"R_SPARC_GOT22", false,0,0x003fffff,false),
HOWTO(R_SPARC_PC10, 0,1,10,false,0,true, true, 0,"R_SPARC_PC10", false,0,0x000003ff,false),
HOWTO(R_SPARC_PC22, 0,2,22,false,0,true, true, 0,"R_SPARC_PC22", false,0,0x003fffff,false),
HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,false,false, 0,"R_SPARC_WPLT30", false,0,0x00000000,false),
HOWTO(R_SPARC_COPY, 0,0,00,false,0,false,false, 0,"R_SPARC_COPY", false,0,0x00000000,false),
HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,false,false,0,"R_SPARC_GLOB_DAT",false,0,0x00000000,false),
HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,false,false,0,"R_SPARC_JMP_SLOT",false,0,0x00000000,false),
HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,false,false,0,"R_SPARC_RELATIVE",false,0,0x00000000,false),
HOWTO(R_SPARC_UA32, 0,0,00,false,0,false,false,0,"R_SPARC_UA32", false,0,0x00000000,false),
HOWTO(R_SPARC_10, 0,1,10,false,0,true, true, 0, "R_SPARC_10", false,0,0x000003ff,false),
HOWTO(R_SPARC_11, 0,1,11,false,0,true, true, 0,"R_SPARC_11", false,0,0x000007ff,false),
HOWTO(R_SPARC_64, 0,4,00,false,0,true, true, 0,"R_SPARC_64", false,0,(((bfd_vma)0xffffffff)<<32)+0xffffffff,false),
HOWTO(R_SPARC_OLO10, 0,1,10,false,0,true,false, DIE,"R_SPARC_OLO10",false,0,0x000003ff,false),
HOWTO(R_SPARC_HH22, 42,2,22,false,0,true, false, 0,"R_SPARC_HH22", false,0,0x003fffff,false),
HOWTO(R_SPARC_HM10, 32,1,10,false,0,true,false, 0,"R_SPARC_HM10", false,0,0x000003ff,false),
HOWTO(R_SPARC_LM22, 10,2,22,false,0,true,false, 0,"R_SPARC_LM22", false,0,0x003fffff,false),
HOWTO(R_SPARC_PC_HH22,42,2,22, true,0,true, false, 0,"R_SPARC_HH22", false,0,0x003fffff,false),
HOWTO(R_SPARC_PC_HM10,32,1,10, true,0,true,false, 0,"R_SPARC_HM10", false,0,0x000003ff,false),
HOWTO(R_SPARC_PC_LM22,10,2,22,true, 0,true,false, 0,"R_SPARC_LM22", false,0,0x003fffff,false),
HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,false, true,DIE,"R_SPARC_WDISP16",false,0,0,false),
HOWTO(R_SPARC_WDISP19, 2,2,22,true, 0,false, true, 0, "R_SPARC_WDISP19",false,0,0x0007ffff,false),
HOWTO(R_SPARC_GLOB_JMP,0,0,00,false,0,false,false,0,"R_SPARC_GLOB_DAT",false,0,0x00000000,false),
HOWTO(R_SPARC_LO7, 0,1, 7,false,0,false,false,0,"R_SPARC_LO7", false,0,0x0000007f,false),
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,false,false, &bfd_elf_generic_reloc,"R_SPARC_NONE", false,0,0x00000000,false),
HOWTO(R_SPARC_8, 0,0, 8,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_8", false,0,0x000000ff,false),
HOWTO(R_SPARC_16, 0,1,16,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_16", false,0,0x0000ffff,false),
HOWTO(R_SPARC_32, 0,2,32,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_32", false,0,0xffffffff,false),
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_DISP8", false,0,0x000000ff,false),
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_DISP16", false,0,0x0000ffff,false),
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_DISP32", false,0,0x00ffffff,false),
HOWTO(R_SPARC_WDISP30,2,2,30,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_WDISP30",false,0,0x3fffffff,true),
HOWTO(R_SPARC_WDISP22,2,2,22,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_WDISP22",false,0,0x003fffff,false),
HOWTO(R_SPARC_HI22, 10,2,22,false,0,true, false, &bfd_elf_generic_reloc,"R_SPARC_HI22", false,0,0x003fffff,false),
HOWTO(R_SPARC_22, 0,2,22,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_22", false,0,0x003fffff,false),
HOWTO(R_SPARC_13, 0,1,13,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_13", false,0,0x00001fff,false),
HOWTO(R_SPARC_LO10, 0,1,10,false,0,true, false, &bfd_elf_generic_reloc,"R_SPARC_LO10", false,0,0x000003ff,false),
HOWTO(R_SPARC_GOT10, 0,1,10,false,0,false, true, &bfd_elf_generic_reloc,"R_SPARC_GOT10", false,0,0x000003ff,false),
HOWTO(R_SPARC_GOT13, 0,1,13,false,0,false, true, &bfd_elf_generic_reloc,"R_SPARC_GOT13", false,0,0x00001fff,false),
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,false, true, &bfd_elf_generic_reloc,"R_SPARC_GOT22", false,0,0x003fffff,false),
HOWTO(R_SPARC_PC10, 0,1,10,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_PC10", false,0,0x000003ff,false),
HOWTO(R_SPARC_PC22, 0,2,22,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_PC22", false,0,0x003fffff,false),
HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,false,false, &bfd_elf_generic_reloc,"R_SPARC_WPLT30", false,0,0x00000000,false),
HOWTO(R_SPARC_COPY, 0,0,00,false,0,false,false, &bfd_elf_generic_reloc,"R_SPARC_COPY", false,0,0x00000000,false),
HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,false),
HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_JMP_SLOT",false,0,0x00000000,false),
HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_RELATIVE",false,0,0x00000000,false),
HOWTO(R_SPARC_UA32, 0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_UA32", false,0,0x00000000,false),
HOWTO(R_SPARC_10, 0,1,10,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_10", false,0,0x000003ff,false),
HOWTO(R_SPARC_11, 0,1,11,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_11", false,0,0x000007ff,false),
HOWTO(R_SPARC_64, 0,4,00,false,0,true, true, &bfd_elf_generic_reloc,"R_SPARC_64", false,0,(((bfd_vma)0xffffffff)<<32)+0xffffffff,false),
HOWTO(R_SPARC_OLO10, 0,1,10,false,0,true,false, &bfd_elf_generic_reloc,"R_SPARC_OLO10",false,0,0x000003ff,false),
HOWTO(R_SPARC_HH22, 42,2,22,false,0,true, false, &bfd_elf_generic_reloc,"R_SPARC_HH22", false,0,0x003fffff,false),
HOWTO(R_SPARC_HM10, 32,1,10,false,0,true,false, &bfd_elf_generic_reloc,"R_SPARC_HM10", false,0,0x000003ff,false),
HOWTO(R_SPARC_LM22, 10,2,22,false,0,true,false, &bfd_elf_generic_reloc,"R_SPARC_LM22", false,0,0x003fffff,false),
HOWTO(R_SPARC_PC_HH22,42,2,22, true,0,true, false, &bfd_elf_generic_reloc,"R_SPARC_HH22", false,0,0x003fffff,false),
HOWTO(R_SPARC_PC_HM10,32,1,10, true,0,true,false, &bfd_elf_generic_reloc,"R_SPARC_HM10", false,0,0x000003ff,false),
HOWTO(R_SPARC_PC_LM22,10,2,22,true, 0,true,false, &bfd_elf_generic_reloc,"R_SPARC_LM22", false,0,0x003fffff,false),
HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,false, true,&bfd_elf_generic_reloc,"R_SPARC_WDISP16",false,0,0,false),
HOWTO(R_SPARC_WDISP19, 2,2,22,true, 0,false, true, &bfd_elf_generic_reloc,"R_SPARC_WDISP19",false,0,0x0007ffff,false),
HOWTO(R_SPARC_GLOB_JMP,0,0,00,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_GLOB_DAT",false,0,0x00000000,false),
HOWTO(R_SPARC_LO7, 0,1, 7,false,0,false,false,&bfd_elf_generic_reloc,"R_SPARC_LO7", false,0,0x0000007f,false),
};
struct elf_reloc_map {

File diff suppressed because it is too large Load Diff

View File

@ -88,17 +88,6 @@ typedef struct
Elf64_External_Sym native_elf_sym;
} elf64_symbol_type;
/* Lacking nested functions and nested types, set up for mapping over
BFD sections to produce ELF sections. */
typedef struct
{
Elf_Internal_Ehdr * i_ehdr;
Elf_Internal_Shdr * i_shdrp;
struct strtab *shstrtab;
int symtab_section;
}
elf_sect_thunk;
struct elf_backend_data
{
int use_rela_p;
@ -108,6 +97,7 @@ struct elf_backend_data
Elf_Internal_Rela *));
void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
Elf_Internal_Rel *));
void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
/* @@ I really don't think this should be here. I don't know what
global_sym is supposed to be used for, but I doubt it's something
@ -119,13 +109,95 @@ struct elf_backend_data
PTR global_sym;
};
extern boolean elf_get_sect_thunk PARAMS ((bfd *, elf_sect_thunk *));
struct bfd_elf_arch_map {
enum bfd_architecture bfd_arch;
int elf_arch;
};
extern const struct bfd_elf_arch_map bfd_elf_arch_map[];
extern const int bfd_elf_arch_map_size;
struct bfd_elf_section_data {
Elf_Internal_Shdr this_hdr;
Elf_Internal_Shdr rel_hdr;
int this_idx, rel_idx;
#if 0
Elf_Internal_Shdr str_hdr;
int str_idx;
#endif
};
#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
#define shdr_name(abfd,shdr) (elf_shstrtab (abfd)->tab + (shdr)->sh_name)
#define get_elf_backend_data(abfd) \
((struct elf_backend_data *) (abfd)->xvec->backend_data)
struct strtab
{
char *tab;
int nentries;
int length;
};
/* Some private data is stashed away for future use using the tdata pointer
in the bfd structure. */
struct elf_obj_tdata
{
Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
Elf_Internal_Shdr **elf_sect_ptr;
struct strtab *strtab_ptr;
int num_locals;
int num_globals;
int *symtab_map;
PTR raw_syms; /* Elf_External_Sym* */
Elf_Internal_Sym *internal_syms;
PTR symbols; /* elf_symbol_type */
/* struct strtab *shstrtab;*/
Elf_Internal_Shdr symtab_hdr;
Elf_Internal_Shdr shstrtab_hdr;
Elf_Internal_Shdr strtab_hdr;
int symtab_section, shstrtab_section, strtab_section;
file_ptr next_file_pos;
void *prstatus; /* The raw /proc prstatus structure */
void *prpsinfo; /* The raw /proc prpsinfo structure */
};
#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
#define elf_symtab_map(bfd) (elf_tdata(bfd) -> symtab_map)
#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
#define obj_symbols(bfd) ((elf_symbol_type*)(elf_tdata(bfd) -> symbols))
#define obj_raw_syms(bfd) ((Elf_External_Sym*)(elf_tdata(bfd) -> raw_syms))
#define obj_internal_syms(bfd) (elf_tdata(bfd) -> internal_syms)
extern char * elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned));
extern char * elf_get_str_section PARAMS ((bfd *, unsigned));
#define bfd_elf32_mkobject bfd_elf_mkobject
#define bfd_elf64_mkobject bfd_elf_mkobject
#define elf_mkobject bfd_elf_mkobject
extern unsigned long elf_hash PARAMS ((CONST unsigned char *));
extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
arelent *,
asymbol *,
PTR,
asection *,
bfd *));
extern boolean bfd_elf_mkobject PARAMS ((bfd *));
extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *));
extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *));
extern bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
extern bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
extern boolean bfd_elf_mkobject PARAMS ((bfd *));
extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *));
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 *,
@ -154,6 +226,7 @@ extern boolean bfd_elf32_find_nearest_line PARAMS ((bfd *, asection *,
CONST char **,
unsigned int *));
extern int bfd_elf32_sizeof_headers PARAMS ((bfd *, boolean));
extern void bfd_elf32__write_relocs PARAMS ((bfd *, asection *, PTR));
extern boolean bfd_elf32_new_section_hook PARAMS ((bfd *, asection *));
/* If the target doesn't have reloc handling written yet: */
@ -162,7 +235,6 @@ extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *,
extern bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
extern bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *));
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 *,
@ -191,61 +263,11 @@ extern boolean bfd_elf64_find_nearest_line PARAMS ((bfd *, asection *,
CONST char **,
unsigned int *));
extern int bfd_elf64_sizeof_headers PARAMS ((bfd *, boolean));
extern void bfd_elf64__write_relocs PARAMS ((bfd *, asection *, PTR));
extern boolean bfd_elf64_new_section_hook PARAMS ((bfd *, asection *));
/* 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 get_elf_backend_data(abfd) \
((struct elf_backend_data *) (abfd)->xvec->backend_data)
struct strtab
{
char *tab;
int nentries;
int length;
};
/* Some private data is stashed away for future use using the tdata pointer
in the bfd structure. */
struct elf_obj_tdata
{
Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
Elf_Internal_Shdr *elf_sect_ptr;
struct strtab *strtab_ptr;
int symtab_section;
int num_locals;
int num_globals;
int *symtab_map;
void *prstatus; /* The raw /proc prstatus structure */
void *prpsinfo; /* The raw /proc prpsinfo structure */
PTR raw_syms; /* Elf_External_Sym* */
Elf_Internal_Sym *internal_syms;
PTR symbols; /* elf_symbol_type */
elf_sect_thunk thunk;
};
#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
#define elf_symtab_map(bfd) (elf_tdata(bfd) -> symtab_map)
#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
#define obj_symbols(bfd) ((elf_symbol_type*)(elf_tdata(bfd) -> symbols))
#define obj_raw_syms(bfd) ((Elf_External_Sym*)(elf_tdata(bfd) -> raw_syms))
#define obj_internal_syms(bfd) (elf_tdata(bfd) -> internal_syms)
extern char * elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned));
extern char * elf_get_str_section PARAMS ((bfd *, unsigned));
#define bfd_elf32_mkobject bfd_elf_mkobject
#define bfd_elf64_mkobject bfd_elf_mkobject
#define elf_mkobject bfd_elf_mkobject
#endif /* _LIBELF_H_ */