aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfcode.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1996-02-14 21:32:24 +0000
committerIan Lance Taylor <ian@airs.com>1996-02-14 21:32:24 +0000
commitc9e5279f23bbe58f0a52cc011bf4a49681b8bb88 (patch)
tree011bf4cbeb02256e77ce7442cf09603c849f8b85 /bfd/elfcode.h
parent90e5f484e5383ca9de51282eb413a3b852a680c4 (diff)
downloadgdb-c9e5279f23bbe58f0a52cc011bf4a49681b8bb88.zip
gdb-c9e5279f23bbe58f0a52cc011bf4a49681b8bb88.tar.gz
gdb-c9e5279f23bbe58f0a52cc011bf4a49681b8bb88.tar.bz2
Wed Feb 14 16:29:07 1996 Martin Anantharaman <martin@mail.imech.uni-duisburg.de>
* syms.c (stt): Add entries for zerovars, vars, and code. * elfcode.h (validate_reloc): New static function. (write_relocs): Call validate_reloc for non ELF relocs. * elfxx-target.h (elf_symbol_leading_char): Define if not defined. (TARGET_BIG_SYM): Use elf_symbol_leading_char. (TARGET_LITTLE_SYM): Likewise. * config.bfd (m68*-*-psos*): New target.
Diffstat (limited to 'bfd/elfcode.h')
-rw-r--r--bfd/elfcode.h123
1 files changed, 122 insertions, 1 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 471521d..85d991d 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -119,6 +119,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
NAME(bfd_elf,link_create_dynamic_sections)
#define elf_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
#define elf_bfd_final_link NAME(bfd_elf,bfd_final_link)
+#define elf_create_pointer_linker_section NAME(bfd_elf,create_pointer_linker_section)
+#define elf_finish_pointer_linker_section NAME(bfd_elf,finish_pointer_linker_section)
#if ARCH_SIZE == 64
#define ELF_R_INFO(X,Y) ELF64_R_INFO(X,Y)
@@ -153,6 +155,7 @@ static boolean elf_slurp_reloc_table PARAMS ((bfd *, asection *, asymbol **));
int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *,
struct symbol_cache_entry **));
+static boolean validate_reloc PARAMS ((bfd *, arelent *));
static void write_relocs PARAMS ((bfd *, asection *, PTR));
boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
@@ -658,9 +661,108 @@ got_no_match:
return (NULL);
}
-
/* ELF .o/exec file writing */
+/* Try to convert a non-ELF reloc into an ELF one. */
+
+static boolean
+validate_reloc (abfd, areloc)
+ bfd *abfd;
+ arelent *areloc;
+{
+ /* Check whether we really have an ELF howto. */
+
+ if ((*areloc->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec)
+ {
+ bfd_reloc_code_real_type code;
+ reloc_howto_type *howto;
+
+ /* Alien reloc: Try to determine its type to replace it with an
+ equivalent ELF reloc. */
+
+ if (areloc->howto->pc_relative)
+ {
+ switch (areloc->howto->bitsize)
+ {
+ case 8:
+ code = BFD_RELOC_8_PCREL;
+ break;
+ case 12:
+ code = BFD_RELOC_12_PCREL;
+ break;
+ case 16:
+ code = BFD_RELOC_16_PCREL;
+ break;
+ case 24:
+ code = BFD_RELOC_24_PCREL;
+ break;
+ case 32:
+ code = BFD_RELOC_32_PCREL;
+ break;
+ case 64:
+ code = BFD_RELOC_64_PCREL;
+ break;
+ default:
+ goto fail;
+ }
+
+ howto = bfd_reloc_type_lookup (abfd, code);
+
+ if (areloc->howto->pcrel_offset != howto->pcrel_offset)
+ {
+ if (howto->pcrel_offset)
+ areloc->addend += areloc->address;
+ else
+ areloc->addend -= areloc->address; /* addend is unsigned!! */
+ }
+ }
+ else
+ {
+ switch (areloc->howto->bitsize)
+ {
+ case 8:
+ code = BFD_RELOC_8;
+ break;
+ case 14:
+ code = BFD_RELOC_14;
+ break;
+ case 16:
+ code = BFD_RELOC_16;
+ break;
+ case 26:
+ code = BFD_RELOC_26;
+ break;
+ case 32:
+ code = BFD_RELOC_32;
+ break;
+ case 64:
+ code = BFD_RELOC_64;
+ break;
+ default:
+ goto fail;
+ }
+
+ howto = bfd_reloc_type_lookup (abfd, code);
+ }
+
+ if (howto)
+ areloc->howto = howto;
+ else
+ goto fail;
+ }
+
+ return true;
+
+ fail:
+ (*_bfd_error_handler)
+ ("%s: unsupported relocation type %s",
+ bfd_get_filename (abfd), areloc->howto->name);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+}
+
+/* Write out the relocs. */
+
static void
write_relocs (abfd, sec, data)
bfd *abfd;
@@ -732,6 +834,14 @@ write_relocs (abfd, sec, data)
last_sym = sym;
last_sym_idx = n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
}
+
+ if ((*areloc->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
+ && ! validate_reloc (abfd, ptr))
+ {
+ *failedp = true;
+ return;
+ }
+
dst_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
dst_rela.r_addend = ptr->addend;
@@ -770,6 +880,14 @@ write_relocs (abfd, sec, data)
last_sym = sym;
last_sym_idx = n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
}
+
+ if ((*areloc->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
+ && ! validate_reloc (abfd, ptr))
+ {
+ *failedp = true;
+ return;
+ }
+
dst_rel.r_info = ELF_R_INFO (n, ptr->howto->type);
elf_swap_reloc_out (abfd, &dst_rel, src_rel);
@@ -974,6 +1092,9 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic)
case STT_FUNC:
sym->symbol.flags |= BSF_FUNCTION;
break;
+ case STT_OBJECT:
+ sym->symbol.flags |= BSF_OBJECT;
+ break;
}
if (dynamic)