This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
H8 assembler changes
- To: binutils at sources dot redhat dot com
- Subject: H8 assembler changes
- From: law at redhat dot com
- Date: Fri, 31 Aug 2001 11:46:36 -0600
- Reply-to: law at redhat dot com
This is a mixture of patches from Joern and myself. Another step closer
to a working H8 ELF assembler port.
* tc-h8300.c (relocation mappings): Remove. Moved to tc-h8300.h.
(build_bytes): Mark fixups for PCrel branches as signed. For
OBJ_ELF, make sure the reloc's offset points to the first byte
to be modified.
(md_convert_frag): Update definiton based on BFD_ASSEMBLER.
* tc-h8300.h (relocation mappings): Add.
Index: tc-h8300.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/config/tc-h8300.c,v
retrieving revision 1.77
diff -c -3 -p -r1.77 tc-h8300.c
*** tc-h8300.c 2001/08/30 20:00:23 1.77
--- tc-h8300.c 2001/08/31 17:30:29
***************
*** 32,49 ****
#ifdef OBJ_ELF
#include "elf/h8.h"
-
- #define R_MOV24B1 BFD_RELOC_H8_DIR24A8
- #define R_MOVL1 BFD_RELOC_H8_DIR32A16
- #define R_MOV24B1 BFD_RELOC_H8_DIR24A8
- #define R_MOVL1 BFD_RELOC_H8_DIR32A16
- #define R_RELLONG BFD_RELOC_32
- #define R_MOV16B1 BFD_RELOC_H8_DIR16A8
- #define R_RELWORD BFD_RELOC_16
- #define R_RELBYTE BFD_RELOC_8
- #define R_PCRWORD BFD_RELOC_16_PCREL
- #define R_PCRBYTE BFD_RELOC_8_PCREL
- #define R_JMPL1 BFD_RELOC_H8_DIR24R8
#endif
const char comment_chars[] = ";";
--- 32,37 ----
*************** build_bytes (this_try, operand)
*** 1110,1115 ****
--- 1126,1132 ----
int where = size16 ? 2 : 1;
int size = size16 ? 2 : 1;
int type = size16 ? R_PCRWORD : R_PCRBYTE;
+ fixS *fixP;
check_operand (operand + i, size16 ? 0x7fff : 0x7f, "@");
*************** build_bytes (this_try, operand)
*** 1119,1134 ****
(unsigned long) operand->exp.X_add_number);
}
operand[i].exp.X_add_number -= 1;
operand[i].exp.X_add_number =
((operand[i].exp.X_add_number & 0xff) ^ 0x80) - 0x80;
! fix_new_exp (frag_now,
! output - frag_now->fr_literal + where,
! size,
! &operand[i].exp,
! 1,
! type);
}
else if (x & MEMIND)
{
--- 1136,1160 ----
(unsigned long) operand->exp.X_add_number);
}
+ #ifndef OBJ_ELF
+ /* The COFF port has always been off by one, changing it
+ now would be an incompatible change, so we leave it as-is.
+
+ We don't want to do this for ELF as we want to be
+ compatible with the proposed ELF format from Hitachi. */
operand[i].exp.X_add_number -= 1;
+ #endif
+
operand[i].exp.X_add_number =
((operand[i].exp.X_add_number & 0xff) ^ 0x80) - 0x80;
! fixP = fix_new_exp (frag_now,
! output - frag_now->fr_literal + where,
! size,
! &operand[i].exp,
! 1,
! type);
! fixP->fx_signed = 1;
}
else if (x & MEMIND)
{
*************** tc_aout_fix_to_chars ()
*** 1448,1454 ****
--- 1474,1484 ----
void
md_convert_frag (headers, seg, fragP)
+ #ifdef BFD_ASSEMBLER
+ bfd *headers ATTRIBUTE_UNUSED;
+ #else
object_headers *headers ATTRIBUTE_UNUSED;
+ #endif
segT seg ATTRIBUTE_UNUSED;
fragS *fragP ATTRIBUTE_UNUSED;
{
Index: tc-h8300.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/config/tc-h8300.h,v
retrieving revision 1.32
diff -c -3 -p -r1.32 tc-h8300.h
*** tc-h8300.h 2001/08/29 18:55:48 1.32
--- tc-h8300.h 2001/08/31 17:30:29
*************** struct internal_reloc;
*** 49,60 ****
--- 49,85 ----
extern void tc_reloc_mangle
PARAMS ((struct fix *, struct internal_reloc *, bfd_vma));
+ #ifdef OBJ_ELF
+ /* Provide mappings from the original H8 COFF relocation names to
+ their corresponding BFD relocation names. This allows us to use
+ most of tc-h8300.c without modifications for both ELF and COFF
+ ports. */
+ #define R_MOV24B1 BFD_RELOC_H8_DIR24A8
+ #define R_MOVL1 BFD_RELOC_H8_DIR32A16
+ #define R_MOV24B1 BFD_RELOC_H8_DIR24A8
+ #define R_MOVL1 BFD_RELOC_H8_DIR32A16
+ #define R_RELLONG BFD_RELOC_32
+ #define R_MOV16B1 BFD_RELOC_H8_DIR16A8
+ #define R_RELWORD BFD_RELOC_16
+ #define R_RELBYTE BFD_RELOC_8
+ #define R_PCRWORD BFD_RELOC_16_PCREL
+ #define R_PCRBYTE BFD_RELOC_8_PCREL
+ #define R_JMPL1 BFD_RELOC_H8_DIR24R8
+ #define R_MEM_INDIRECT BFD_RELOC_8
+
+ /* We do not want to adjust any relocations to make implementation of
+ linker relaxations easier. */
+ #define tc_fix_adjustable(FIX) 0
+ #endif
+
#define TC_CONS_RELOC (Hmode ? R_RELLONG: R_RELWORD)
#define DO_NOT_STRIP 0
#define LISTING_HEADER "Hitachi H8/300 GAS "
#define NEED_FX_R_TYPE 1
+ #ifndef OBJ_ELF
#define RELOC_32 1234
+ #endif
extern int Hmode;
extern int Smode;