/* i370-specific support for 32-bit ELF
- Copyright 1994, 95, 96, 97, 98, 2000 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001
+ Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-
/* This file is based on a preliminary PowerPC ELF ABI.
But its been hacked on for the IBM 360/370 architectures.
Basically, the 31bit relocation works, and just about everything
dynamic loading to work ... its never been tested ...
*/
-
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"
R_I370_max
};
-
\f
static reloc_howto_type *i370_elf_howto_table[ (int)R_I370_max ];
false), /* pcrel_offset */
};
-
\f
static void i370_elf_howto_init PARAMS ((void));
+static reloc_howto_type *i370_elf_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+
static void i370_elf_info_to_howto PARAMS ((bfd *abfd, arelent *cache_ptr,
Elf32_Internal_Rela *dst));
static boolean i370_elf_set_private_flags PARAMS ((bfd *, flagword));
-
\f
/* Initialize the i370_elf_howto_table, so that linear accesses can be done. */
for (i = 0; i < sizeof (i370_elf_howto_raw) / sizeof (i370_elf_howto_raw[0]); i++)
{
type = i370_elf_howto_raw[i].type;
- BFD_ASSERT (type < sizeof(i370_elf_howto_table) / sizeof(i370_elf_howto_table[0]));
+ BFD_ASSERT (type < sizeof (i370_elf_howto_table) / sizeof (i370_elf_howto_table[0]));
i370_elf_howto_table[type] = &i370_elf_howto_raw[i];
}
}
-
\f
static reloc_howto_type *
i370_elf_reloc_type_lookup (abfd, code)
Elf_Internal_Rela *relocs,
Elf_Internal_Sym *local_syms,
asection **));
+static void i370_elf_post_process_headers
+ PARAMS ((bfd *, struct bfd_link_info *));
static boolean i370_elf_create_dynamic_sections PARAMS ((bfd *,
struct bfd_link_info *));
#define ELF_DYNAMIC_INTERPRETER "/lib/ld.so"
-
/* Set the howto pointer for an i370 ELF reloc. */
static void
/* hack alert -- the following several routines look generic to me ...
* why are we bothering with them ???
*/
-/* Function to set whether a module needs the -mrelocatable bit set. */
+/* Function to set whether a module needs the -mrelocatable bit set. */
static boolean
i370_elf_set_private_flags (abfd, flags)
bfd *abfd;
{
(*_bfd_error_handler)
("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
- bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
+ bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags);
bfd_set_error (bfd_error_bad_value);
return false;
return true;
}
-
\f
/* Handle an i370 specific section when reading an object file. This
is called when elfcode.h finds a section with an unknown type. */
bfd_set_section_flags (abfd, newsect, flags);
return true;
}
-
-
\f
/* Set up any other section flags and such that may be necessary. */
/* XXX hack alert bogus This routine is mostly all junk and almost
* just enough to allow glibc-2.1 ld.so to compile & link.
*/
-
static boolean
i370_elf_fake_sections (abfd, shdr, asect)
bfd *abfd ATTRIBUTE_UNUSED;
return true;
}
-
\f
#if 0
/* Create a special linker section */
{
default:
(*_bfd_error_handler) ("%s: Unknown special linker type %d",
- bfd_get_filename (abfd),
- (int)which);
+ bfd_archive_filename (abfd),
+ (int) which);
bfd_set_error (bfd_error_bad_value);
return (elf_linker_section_t *)0;
return false;
}
- /* xxx beats me, seem to need a rela.text ... */
+ /* xxx beats me, seem to need a rela.text ... */
s = bfd_make_section (abfd, ".rela.text");
if (s == NULL
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
&& (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0)));
-
s = bfd_get_section_by_name (dynobj, ".rela.text");
BFD_ASSERT (s != NULL);
s->_raw_size += sizeof (Elf32_External_Rela);
return true;
}
-
\f
/* Increment the index of a dynamic symbol by a given amount. Called
via elf_link_hash_traverse. */
return true;
}
-
\f
/* Set the sizes of the dynamic sections. */
/* XXX hack alert bogus This routine is mostly all junk and almost
asection *target;
const char *outname;
- /* Remember whether there are any relocation sections. */
+ /* Remember whether there are any relocation sections. */
relocs = true;
/* If this relocation section applies to a read only
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
}
if (reltext)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
+ info->flags |= DF_TEXTREL;
}
}
+#undef add_dynamic_entry
/* If we are generating a shared library, we generate a section
symbol for each output section. These are local symbols, which
return true;
}
-
\f
/* Look through the relocs for a section during the first phase, and
allocate space in the global offset table or procedure linkage
#ifdef DEBUG
fprintf (stderr, "i370_elf_check_relocs called for section %s in %s\n",
bfd_get_section_name (abfd, sec),
- bfd_get_filename (abfd));
+ bfd_archive_filename (abfd));
#endif
dynobj = elf_hash_table (info)->dynobj;
return true;
}
-
\f
/* Finish up the dynamic sections. */
/* XXX hack alert bogus This routine is mostly all junk and almost
if (sgot)
{
unsigned char *contents = sgot->contents;
- bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);
+ bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents);
if (sdyn == NULL)
bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4);
return true;
}
-
\f
/* The RELOCATE_SECTION function is called by the ELF backend linker
to handle the relocations for a section.
#ifdef DEBUG
fprintf (stderr, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n",
- bfd_get_filename (input_bfd),
+ bfd_archive_filename (input_bfd),
bfd_section_name(input_bfd, input_section),
- (long)input_section->reloc_count,
+ (long) input_section->reloc_count,
(info->relocateable) ? " (relocatable)" : "");
#endif
|| !i370_elf_howto_table[(int)r_type])
{
(*_bfd_error_handler) ("%s: unknown relocation type %d",
- bfd_get_filename (input_bfd),
- (int)r_type);
+ bfd_archive_filename (input_bfd),
+ (int) r_type);
bfd_set_error (bfd_error_bad_value);
ret = false;
relocation = 0;
else
{
- (*info->callbacks->undefined_symbol)(info,
- h->root.root.string,
- input_bfd,
- input_section,
- rel->r_offset,
- true);
+ (*info->callbacks->undefined_symbol) (info,
+ h->root.root.string,
+ input_bfd,
+ input_section,
+ rel->r_offset,
+ true);
ret = false;
continue;
}
}
- switch ((int)r_type)
+ switch ((int) r_type)
{
default:
- (*_bfd_error_handler) ("%s: unknown relocation type %d for symbol %s",
- bfd_get_filename (input_bfd),
- (int)r_type, sym_name);
+ (*_bfd_error_handler)
+ ("%s: unknown relocation type %d for symbol %s",
+ bfd_archive_filename (input_bfd),
+ (int) r_type, sym_name);
bfd_set_error (bfd_error_bad_value);
ret = false;
#ifdef DEBUG
if (indx <= 0)
{
- printf("indx=%d section=%s flags=%08x name=%s\n",
- indx, osec->name, osec->flags,
- h->root.root.string);
+ printf ("indx=%d section=%s flags=%08x name=%s\n",
+ indx, osec->name, osec->flags,
+ h->root.root.string);
}
#endif
}
case (int)R_I370_COPY:
case (int)R_I370_RELATIVE:
- (*_bfd_error_handler) ("%s: Relocation %s is not yet supported for symbol %s.",
- bfd_get_filename (input_bfd),
- i370_elf_howto_table[ (int)r_type ]->name,
- sym_name);
+ (*_bfd_error_handler)
+ ("%s: Relocation %s is not yet supported for symbol %s.",
+ bfd_archive_filename (input_bfd),
+ i370_elf_howto_table[(int) r_type]->name,
+ sym_name);
bfd_set_error (bfd_error_invalid_operation);
ret = false;
continue;
}
-
#ifdef DEBUG
fprintf (stderr, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n",
howto->name,
name = bfd_section_name (input_bfd, sec);
}
- (*info->callbacks->reloc_overflow)(info,
- name,
- howto->name,
- (bfd_vma) 0,
- input_bfd,
- input_section,
- offset);
+ (*info->callbacks->reloc_overflow) (info,
+ name,
+ howto->name,
+ (bfd_vma) 0,
+ input_bfd,
+ input_section,
+ offset);
}
break;
}
}
-
#ifdef DEBUG
fprintf (stderr, "\n");
#endif
#define ELF_MAXPAGESIZE 0x1000
#define elf_info_to_howto i370_elf_info_to_howto
-
-
#define elf_backend_plt_not_loaded 1
#define elf_backend_got_symbol_offset 4
#define elf_backend_post_process_headers i370_elf_post_process_headers
-int i370_noop()
+static int i370_noop PARAMS ((void));
+
+static int i370_noop ()
{
return 1;
}
#define elf_backend_add_symbol_hook \
(boolean (*) PARAMS ((bfd *, struct bfd_link_info *, \
const Elf_Internal_Sym *, const char **, flagword *, \
- asection **, bfd_vma *))) i370_noop
+ asection **, bfd_vma *))) i370_noop
#define elf_backend_finish_dynamic_symbol \
(boolean (*) PARAMS ((bfd *, struct bfd_link_info *, \
struct elf_link_hash_entry *, \