diff options
author | obrien <obrien@FreeBSD.org> | 2001-06-26 17:15:34 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-06-26 17:15:34 +0000 |
commit | ae921d7c71a80f740581790f46ff9bc111a17f00 (patch) | |
tree | a1a560267d1745ccd4e0d063cacf68ed9192ee43 /contrib | |
parent | 080df9bfad9e4544b1f9aa91c3f7a9b6fe10d0dc (diff) | |
download | FreeBSD-src-ae921d7c71a80f740581790f46ff9bc111a17f00.zip FreeBSD-src-ae921d7c71a80f740581790f46ff9bc111a17f00.tar.gz |
Merge rev 1.8 (only define "ELF_DYNAMIC_INTERPRETER" if it isn't defined
elsewhere.) into Binutils 2.11.2.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/binutils/bfd/elf32-i386.c | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/contrib/binutils/bfd/elf32-i386.c b/contrib/binutils/bfd/elf32-i386.c index c216a00..d6c2dd7 100644 --- a/contrib/binutils/bfd/elf32-i386.c +++ b/contrib/binutils/bfd/elf32-i386.c @@ -1,5 +1,5 @@ /* Intel 80386/80486-specific support for 32-bit ELF - Copyright 1993, 94, 95, 96, 97, 98, 99, 2000 + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -507,6 +507,20 @@ elf_i386_check_relocs (abfd, info, sec, relocs) r_symndx = ELF32_R_SYM (rel->r_info); + if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) + { + if (abfd->my_archive) + (*_bfd_error_handler) (_("%s(%s): bad symbol index: %d"), + bfd_get_filename (abfd->my_archive), + bfd_get_filename (abfd), + r_symndx); + else + (*_bfd_error_handler) (_("%s: bad symbol index: %d"), + bfd_get_filename (abfd), + r_symndx); + return false; + } + if (r_symndx < symtab_hdr->sh_info) h = NULL; else @@ -692,7 +706,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs) (*_bfd_error_handler) (_("%s: bad relocation section name `%s\'"), bfd_get_filename (abfd), name); - } + } sreloc = bfd_get_section_by_name (dynobj, name); if (sreloc == NULL) @@ -824,7 +838,7 @@ elf_i386_gc_mark_hook (abfd, info, rel, h, sym) static boolean elf_i386_gc_sweep_hook (abfd, info, sec, relocs) bfd *abfd; - struct bfd_link_info *info ATTRIBUTE_UNUSED; + struct bfd_link_info *info; asection *sec; const Elf_Internal_Rela *relocs; { @@ -2072,6 +2086,44 @@ elf_i386_finish_dynamic_sections (output_bfd, info) return true; } +/* Set the correct type for an x86 ELF section. We do this by the + section name, which is a hack, but ought to work. */ + +static boolean +elf_i386_fake_sections (abfd, hdr, sec) + bfd *abfd ATTRIBUTE_UNUSED; + Elf32_Internal_Shdr *hdr; + asection *sec; +{ + register const char *name; + + name = bfd_get_section_name (abfd, sec); + + if (strcmp (name, ".reloc") == 0) + /* + * This is an ugly, but unfortunately necessary hack that is + * needed when producing EFI binaries on x86. It tells + * elf.c:elf_fake_sections() not to consider ".reloc" as a section + * containing ELF relocation info. We need this hack in order to + * be able to generate ELF binaries that can be translated into + * EFI applications (which are essentially COFF objects). Those + * files contain a COFF ".reloc" section inside an ELFNN object, + * which would normally cause BFD to segfault because it would + * attempt to interpret this section as containing relocation + * entries for section "oc". With this hack enabled, ".reloc" + * will be treated as a normal data section, which will avoid the + * segfault. However, you won't be able to create an ELFNN binary + * with a section named "oc" that needs relocations, but that's + * the kind of ugly side-effects you get when detecting section + * types based on their names... In practice, this limitation is + * unlikely to bite. + */ + hdr->sh_type = SHT_PROGBITS; + + return true; +} + + #define TARGET_LITTLE_SYM bfd_elf32_i386_vec #define TARGET_LITTLE_NAME "elf32-i386" #define ELF_ARCH bfd_arch_i386 @@ -2102,5 +2154,6 @@ elf_i386_finish_dynamic_sections (output_bfd, info) #define elf_backend_gc_sweep_hook elf_i386_gc_sweep_hook #define elf_backend_relocate_section elf_i386_relocate_section #define elf_backend_size_dynamic_sections elf_i386_size_dynamic_sections +#define elf_backend_fake_sections elf_i386_fake_sections #include "elf32-target.h" |