This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
More H8 ELF BFD changes
- To: binutils at sources dot redhat dot com
- Subject: More H8 ELF BFD changes
- From: law at redhat dot com
- Date: Tue, 04 Sep 2001 19:31:07 -0600
- Reply-to: law at redhat dot com
This is mostly cleanup issues (warning fixes, copyright dates, etc). It
does fix the H8 ELF BFD backend to encode machine/architecture info in a
way that is compatible with the proposed specs from Hitachi.
* elf32-h8300.c: Fix copyright dates. Add various missing prototypes.
(elf32_h8_mach): Remove.
(elf32_h8_final_write_processing): Store arch/machine info into
e_machine field in the ELF header.
(elf32_h8_object_p): Retrieve arch/machine info from e_machine
field in the ELF header.
(elf32_h8_relax_section): Ignore relocs which are not relaxable.
(ELF_MACHINE_ALT1, ELF_MACHINE_ALT2): Define.
Index: elf32-h8300.c
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/elf32-h8300.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 elf32-h8300.c
*** elf32-h8300.c 2001/09/04 21:08:43 1.7
--- elf32-h8300.c 2001/09/05 01:24:34
***************
*** 1,5 ****
/* Generic support for 32-bit ELF
! Copyright 1993, 1995, 1998, 1999 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
--- 1,5 ----
/* Generic support for 32-bit ELF
! Copyright 1993, 1995, 1998, 1999, 2001 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
*************** static void elf32_h8_info_to_howto
*** 29,36 ****
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static void elf32_h8_info_to_howto_rel
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
! static int elf32_h8_mach
! PARAMS ((flagword));
static bfd_reloc_status_type elf32_h8_final_link_relocate
PARAMS ((unsigned long, bfd *, bfd *, asection *,
bfd_byte *, bfd_vma, bfd_vma, bfd_vma,
--- 29,36 ----
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static void elf32_h8_info_to_howto_rel
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
! static bfd_reloc_status_type special
! PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type elf32_h8_final_link_relocate
PARAMS ((unsigned long, bfd *, bfd *, asection *,
bfd_byte *, bfd_vma, bfd_vma, bfd_vma,
*************** static boolean elf32_h8_relocate_section
*** 39,46 ****
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
bfd_byte *, Elf_Internal_Rela *,
Elf_Internal_Sym *, asection **));
! static bfd_reloc_status_type special
! PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
/* This does not include any relocation information, but should be
good enough for GDB or objdump to read the file. */
--- 39,59 ----
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
bfd_byte *, Elf_Internal_Rela *,
Elf_Internal_Sym *, asection **));
! static void elf32_h8_final_write_processing
! PARAMS ((bfd *, boolean));
! static boolean elf32_h8_object_p
! PARAMS ((bfd *));
! static boolean elf32_h8_merge_private_bfd_data
! PARAMS ((bfd *, bfd *));
! static boolean elf32_h8_relax_section
! PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
! static boolean elf32_h8_relax_delete_bytes
! PARAMS ((bfd *, asection *, bfd_vma, int));
! static boolean elf32_h8_symbol_address_p
! PARAMS ((bfd *, asection *, Elf32_External_Sym *, bfd_vma));
! static bfd_byte * elf32_h8_get_relocated_section_contents
! PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
! bfd_byte *, boolean, asymbol **));
/* This does not include any relocation information, but should be
good enough for GDB or objdump to read the file. */
*************** elf32_h8_relocate_section (output_bfd, i
*** 559,592 ****
return true;
}
- /* Object files encode the specific H8 model they were compiled
- for in the ELF flags field.
-
- Examine that field and return the proper BFD machine type for
- the object file. */
- static int
- elf32_h8_mach (flags)
- flagword flags;
- {
- switch (flags & EF_H8_MACH)
- {
- case E_H8_MACH_H8300:
- default:
- return bfd_mach_h8300;
-
- case E_H8_MACH_H8300H:
- return bfd_mach_h8300h;
-
- case E_H8_MACH_H8300S:
- return bfd_mach_h8300s;
- }
- }
-
/* The final processing done just before writing out a H8 ELF object
file. We use this opportunity to encode the BFD machine type
into the flags field in the object file. */
! void
elf32_h8_final_write_processing (abfd, linker)
bfd *abfd;
boolean linker ATTRIBUTE_UNUSED;
--- 572,582 ----
return true;
}
/* The final processing done just before writing out a H8 ELF object
file. We use this opportunity to encode the BFD machine type
into the flags field in the object file. */
! static void
elf32_h8_final_write_processing (abfd, linker)
bfd *abfd;
boolean linker ATTRIBUTE_UNUSED;
*************** elf32_h8_final_write_processing (abfd, l
*** 597,627 ****
{
default:
case bfd_mach_h8300:
! val = E_H8_MACH_H8300;
break;
case bfd_mach_h8300h:
! val = E_H8_MACH_H8300H;
break;
case bfd_mach_h8300s:
! val = E_H8_MACH_H8300S;
break;
}
! elf_elfheader (abfd)->e_flags &= ~ (EF_H8_MACH);
! elf_elfheader (abfd)->e_flags |= val;
}
/* Return nonzero if ABFD represents a valid H8 ELF object file; also
record the encoded machine type found in the ELF flags. */
! boolean
elf32_h8_object_p (abfd)
bfd *abfd;
{
! bfd_default_set_arch_mach (abfd, bfd_arch_h8300,
! elf32_h8_mach (elf_elfheader (abfd)->e_flags));
return true;
}
--- 587,631 ----
{
default:
case bfd_mach_h8300:
! val = EM_H8_300;
break;
case bfd_mach_h8300h:
! val = EM_H8_300H;
break;
case bfd_mach_h8300s:
! val = EM_H8S;
break;
}
! elf_elfheader (abfd)->e_machine = val;
}
/* Return nonzero if ABFD represents a valid H8 ELF object file; also
record the encoded machine type found in the ELF flags. */
! static boolean
elf32_h8_object_p (abfd)
bfd *abfd;
{
! switch (elf_elfheader(abfd)->e_machine)
! {
! case EM_H8_300:
! bfd_default_set_arch_mach (abfd, bfd_arch_h8300,
! bfd_mach_h8300);
! break;
! case EM_H8_300H:
! bfd_default_set_arch_mach (abfd, bfd_arch_h8300,
! bfd_mach_h8300h);
! break;
! case EM_H8S:
! bfd_default_set_arch_mach (abfd, bfd_arch_h8300,
! bfd_mach_h8300s);
! break;
! default:
! return false;
! }
return true;
}
*************** elf32_h8_object_p (abfd)
*** 629,635 ****
object file when linking. The only data we need to copy at this
time is the architecture/machine information. */
! boolean
elf32_h8_merge_private_bfd_data (ibfd, obfd)
bfd *ibfd;
bfd *obfd;
--- 633,639 ----
object file when linking. The only data we need to copy at this
time is the architecture/machine information. */
! static boolean
elf32_h8_merge_private_bfd_data (ibfd, obfd)
bfd *ibfd;
bfd *obfd;
*************** elf32_h8_merge_private_bfd_data (ibfd, o
*** 664,674 ****
mov.b:16 -> mov.b:8 2 bytes
mov.b:24/32 -> mov.b:8 4 bytes
! mov.[bwl]:24/32 -> mov.[bwl]:16 2 bytes
!
- */
-
static boolean
elf32_h8_relax_section (abfd, sec, link_info, again)
bfd *abfd;
--- 668,675 ----
mov.b:16 -> mov.b:8 2 bytes
mov.b:24/32 -> mov.b:8 4 bytes
! mov.[bwl]:24/32 -> mov.[bwl]:16 2 bytes */
static boolean
elf32_h8_relax_section (abfd, sec, link_info, again)
bfd *abfd;
*************** elf32_h8_relax_section (abfd, sec, link_
*** 731,736 ****
--- 732,744 ----
if (irel != internal_relocs)
last_reloc = irel - 1;
+ if (ELF32_R_TYPE (irel->r_info) != R_H8_DIR24R8
+ && ELF32_R_TYPE (irel->r_info) != R_H8_PCREL16
+ && ELF32_R_TYPE (irel->r_info) != R_H8_DIR16A8
+ && ELF32_R_TYPE (irel->r_info) != R_H8_DIR24A8
+ && ELF32_R_TYPE (irel->r_info) != R_H8_DIR32A16)
+ continue;
+
/* Get the section contents if we haven't done so already. */
if (contents == NULL)
{
*************** elf32_h8_get_relocated_section_contents
*** 1508,1513 ****
--- 1516,1523 ----
#define TARGET_BIG_NAME "elf32-h8300"
#define ELF_ARCH bfd_arch_h8300
#define ELF_MACHINE_CODE EM_H8_300
+ #define ELF_MACHINE_ALT1 EM_H8_300H
+ #define ELF_MACHINE_ALT2 EM_H8S
#define ELF_MAXPAGESIZE 0x1
#define bfd_elf32_bfd_reloc_type_lookup elf32_h8_reloc_type_lookup
#define elf_info_to_howto elf32_h8_info_to_howto