public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] new sh relocs
@ 2003-08-15 20:51 DJ Delorie
  2003-08-16  5:19 ` Ian Lance Taylor
  0 siblings, 1 reply; 13+ messages in thread
From: DJ Delorie @ 2003-08-15 20:51 UTC (permalink / raw)
  To: binutils


Renesas has asked us to implement more of the "official" relocations.
Unfortunately, we had some GNU reloc extensions in those numbers, so I
had to move some of them to the reserved slots.  Note that nearly all
reloc values from 1 to 127 are used by SH, so we should expect more of
this type of thing in the future.  They also define bit 7 of the type
to mean something, so in reality, they've used up all the relocations.

I've hooked up the DIR16 and DIR8 relocs so they can be used and
tested with gas, but the rest are effectively untestable at this time
(I assume they're for interlinkability with the SHC compiler).

2003-08-15  DJ Delorie  <dj@redhat.com>

	* sh.h (R_SH_SWITCH8, R_SH_GNU_VTINHERIT, R_SH_GNU_VTENTRY,
	R_SH_LOOP_START,R_SH_LOOP_END): Move to "reserved" spaces.
	(R_SH_DIR16, R_SH_DIR8, R_SH_DIR8UL, R_SH_DIR8UW, R_SH_DIR8U,
	R_SH_DIR8SW, R_SH_DIR8S, R_SH_DIR4UL, R_SH_DIR4UW, R_SH_DIR4U,
	R_SH_PSHA, R_SH_PSHL): New.

2003-08-15  DJ Delorie  <dj@redhat.com>

	* elf32-sh.c (sh_elf_howto_table): R_SH_SWITCH8,
	R_SH_GNU_VTINHERIT, R_SH_GNU_VTENTRY,
	R_SH_LOOP_START,R_SH_LOOP_END moved to "reserved" spaces,
	R_SH_DIR16, R_SH_DIR8, R_SH_DIR8UL, R_SH_DIR8UW, R_SH_DIR8U,
	R_SH_DIR8SW, R_SH_DIR8S, R_SH_DIR4UL, R_SH_DIR4UW, R_SH_DIR4U,
	R_SH_PSHA, R_SH_PSHL added.
	(sh_reloc_map): Add R_SH_DIR16 and R_SH_DIR8.
	(sh_elf_relocate_section): Support new relocs.


Index: include/elf/sh.h
===================================================================
RCS file: /cvs/uberbaum/./include/elf/sh.h,v
retrieving revision 1.14
diff -p -2 -r1.14  include/elf/sh.h
*** include/elf/sh.h	3 Mar 2003 21:03:58 -0000	1.14
--- include/elf/sh.h	15 Aug 2003 20:48:05 -0000
***************
*** 84,89 ****
  
  /* Relocations.  */
! /* Relocations 25ff are GNU extensions.
!    25..33 are used for relaxation and use the same constants as COFF uses.  */
  START_RELOC_NUMBERS (elf_sh_reloc_type)
    RELOC_NUMBER (R_SH_NONE, 0)
--- 84,89 ----
  
  /* Relocations.  */
! /* Relocations 10-32 and 128-255 are GNU extensions.
!    25..32 and 10 are used for relaxation.  */
  START_RELOC_NUMBERS (elf_sh_reloc_type)
    RELOC_NUMBER (R_SH_NONE, 0)
*************** START_RELOC_NUMBERS (elf_sh_reloc_type)
*** 97,101 ****
    RELOC_NUMBER (R_SH_DIR8W, 8)
    RELOC_NUMBER (R_SH_DIR8L, 9)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC, 10)
    FAKE_RELOC (R_SH_LAST_INVALID_RELOC, 24)
    RELOC_NUMBER (R_SH_SWITCH16, 25)
--- 97,106 ----
    RELOC_NUMBER (R_SH_DIR8W, 8)
    RELOC_NUMBER (R_SH_DIR8L, 9)
!   RELOC_NUMBER (R_SH_SWITCH8, 10)
!   RELOC_NUMBER (R_SH_GNU_VTINHERIT, 11)
!   RELOC_NUMBER (R_SH_GNU_VTENTRY, 12)
!   RELOC_NUMBER (R_SH_LOOP_START, 13)
!   RELOC_NUMBER (R_SH_LOOP_END, 14)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC, 15)
    FAKE_RELOC (R_SH_LAST_INVALID_RELOC, 24)
    RELOC_NUMBER (R_SH_SWITCH16, 25)
*************** START_RELOC_NUMBERS (elf_sh_reloc_type)
*** 107,117 ****
    RELOC_NUMBER (R_SH_DATA, 31)
    RELOC_NUMBER (R_SH_LABEL, 32)
!   RELOC_NUMBER (R_SH_SWITCH8, 33)
!   RELOC_NUMBER (R_SH_GNU_VTINHERIT, 34)
!   RELOC_NUMBER (R_SH_GNU_VTENTRY, 35)
!   RELOC_NUMBER (R_SH_LOOP_START, 36)
!   RELOC_NUMBER (R_SH_LOOP_END, 37)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_2, 38)
!   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_2, 44)
    RELOC_NUMBER (R_SH_DIR5U, 45)
    RELOC_NUMBER (R_SH_DIR6U, 46)
--- 112,127 ----
    RELOC_NUMBER (R_SH_DATA, 31)
    RELOC_NUMBER (R_SH_LABEL, 32)
!   RELOC_NUMBER (R_SH_DIR16, 33)
!   RELOC_NUMBER (R_SH_DIR8, 34)
!   RELOC_NUMBER (R_SH_DIR8UL, 35)
!   RELOC_NUMBER (R_SH_DIR8UW, 36)
!   RELOC_NUMBER (R_SH_DIR8U, 37)
!   RELOC_NUMBER (R_SH_DIR8SW, 38)
!   RELOC_NUMBER (R_SH_DIR8S, 39)
!   RELOC_NUMBER (R_SH_DIR4UL, 40)
!   RELOC_NUMBER (R_SH_DIR4UW, 41)
!   RELOC_NUMBER (R_SH_DIR4U, 42)
!   RELOC_NUMBER (R_SH_PSHA, 43)
!   RELOC_NUMBER (R_SH_PSHL, 44)
    RELOC_NUMBER (R_SH_DIR5U, 45)
    RELOC_NUMBER (R_SH_DIR6U, 46)
*************** START_RELOC_NUMBERS (elf_sh_reloc_type)
*** 121,125 ****
    RELOC_NUMBER (R_SH_DIR10SL, 50)
    RELOC_NUMBER (R_SH_DIR10SQ, 51)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_3, 52)
    FAKE_RELOC (R_SH_LAST_INVALID_RELOC_3, 143)
    RELOC_NUMBER (R_SH_TLS_GD_32, 144)
--- 131,138 ----
    RELOC_NUMBER (R_SH_DIR10SL, 50)
    RELOC_NUMBER (R_SH_DIR10SQ, 51)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_2, 52)
!   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_2, 52)
!   RELOC_NUMBER (R_SH_DIR16S, 53)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_3, 54)
    FAKE_RELOC (R_SH_LAST_INVALID_RELOC_3, 143)
    RELOC_NUMBER (R_SH_TLS_GD_32, 144)
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/uberbaum/./bfd/elf32-sh.c,v
retrieving revision 1.90
diff -p -2 -r1.90  bfd/elf32-sh.c
*** bfd/elf32-sh.c	11 Aug 2003 14:26:10 -0000	1.90
--- bfd/elf32-sh.c	15 Aug 2003 20:48:06 -0000
*************** static reloc_howto_type sh_elf_howto_tab
*** 277,285 ****
  	 TRUE),			/* pcrel_offset */
  
!   EMPTY_HOWTO (10),
!   EMPTY_HOWTO (11),
!   EMPTY_HOWTO (12),
!   EMPTY_HOWTO (13),
!   EMPTY_HOWTO (14),
    EMPTY_HOWTO (15),
    EMPTY_HOWTO (16),
--- 277,357 ----
  	 TRUE),			/* pcrel_offset */
  
!   /* An 8 bit switch table entry.  This is generated for an expression
!      such as ``.word L1 - L2''.  The offset holds the difference
!      between the reloc address and L2.  */
!   HOWTO (R_SH_SWITCH8,		/* type */
! 	 0,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_SWITCH8",	/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
! 
!   /* GNU extension to record C++ vtable hierarchy */
!   HOWTO (R_SH_GNU_VTINHERIT, /* type */
! 	 0,			/* rightshift */
! 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 0,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_dont, /* complain_on_overflow */
! 	 NULL,			/* special_function */
! 	 "R_SH_GNU_VTINHERIT", /* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   /* GNU extension to record C++ vtable member usage */
!   HOWTO (R_SH_GNU_VTENTRY,     /* type */
! 	 0,			/* rightshift */
! 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 0,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_dont, /* complain_on_overflow */
! 	 _bfd_elf_rel_vtable_reloc_fn,	/* special_function */
! 	 "R_SH_GNU_VTENTRY",   /* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
!   HOWTO (R_SH_LOOP_START,	/* type */
! 	 1,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_LOOP_START",	/* name */
! 	 TRUE,			/* partial_inplace */
! 	 0xff,			/* src_mask */
! 	 0xff,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
! 
!   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
!   HOWTO (R_SH_LOOP_END,		/* type */
! 	 1,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_LOOP_END",	/* name */
! 	 TRUE,			/* partial_inplace */
! 	 0xff,			/* src_mask */
! 	 0xff,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
! 
    EMPTY_HOWTO (15),
    EMPTY_HOWTO (16),
*************** static reloc_howto_type sh_elf_howto_tab
*** 435,443 ****
  	 TRUE),			/* pcrel_offset */
  
!   /* An 8 bit switch table entry.  This is generated for an expression
!      such as ``.word L1 - L2''.  The offset holds the difference
!      between the reloc address and L2.  */
!   HOWTO (R_SH_SWITCH8,		/* type */
  	 0,			/* rightshift */
  	 0,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
--- 507,541 ----
  	 TRUE),			/* pcrel_offset */
  
!   /* The next 12 are only supported via linking in SHC-generated objects.  */
!   HOWTO (R_SH_DIR16,		/* type */
  	 0,			/* rightshift */
+ 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+ 	 16,			/* bitsize */
+ 	 FALSE,			/* pc_relative */
+ 	 0,			/* bitpos */
+ 	 complain_overflow_dont, /* complain_on_overflow */
+ 	 bfd_elf_generic_reloc,	/* special_function */
+ 	 "R_SH_DIR16",		/* name */
+ 	 FALSE,			/* partial_inplace */
+ 	 0,			/* src_mask */
+ 	 0xffff,		/* dst_mask */
+ 	 FALSE),		/* pcrel_offset */
+ 
+   HOWTO (R_SH_DIR8,		/* type */
+ 	 0,			/* rightshift */
+ 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+ 	 8,			/* bitsize */
+ 	 FALSE,			/* pc_relative */
+ 	 0,			/* bitpos */
+ 	 complain_overflow_dont, /* complain_on_overflow */
+ 	 bfd_elf_generic_reloc,	/* special_function */
+ 	 "R_SH_DIR8",		/* name */
+ 	 FALSE,			/* partial_inplace */
+ 	 0,			/* src_mask */
+ 	 0xff,			/* dst_mask */
+ 	 FALSE),		/* pcrel_offset */
+ 
+   HOWTO (R_SH_DIR8UL,		/* type */
+ 	 2,			/* rightshift */
  	 0,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
*************** static reloc_howto_type sh_elf_howto_tab
*** 445,522 ****
  	 0,			/* bitpos */
  	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_SWITCH8",	/* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
  
!   /* GNU extension to record C++ vtable hierarchy */
!   HOWTO (R_SH_GNU_VTINHERIT, /* type */
! 	 0,			/* rightshift */
! 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 0,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
! 	 complain_overflow_dont, /* complain_on_overflow */
! 	 NULL,			/* special_function */
! 	 "R_SH_GNU_VTINHERIT", /* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0,			/* dst_mask */
  	 FALSE),		/* pcrel_offset */
  
!   /* GNU extension to record C++ vtable member usage */
!   HOWTO (R_SH_GNU_VTENTRY,     /* type */
  	 0,			/* rightshift */
! 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 0,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
! 	 complain_overflow_dont, /* complain_on_overflow */
! 	 _bfd_elf_rel_vtable_reloc_fn,	/* special_function */
! 	 "R_SH_GNU_VTENTRY",   /* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0,			/* dst_mask */
  	 FALSE),		/* pcrel_offset */
  
!   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
!   HOWTO (R_SH_LOOP_START,	/* type */
  	 1,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_signed, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_LOOP_START",	/* name */
! 	 TRUE,			/* partial_inplace */
! 	 0xff,			/* src_mask */
  	 0xff,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
  
!   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
!   HOWTO (R_SH_LOOP_END,		/* type */
! 	 1,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_signed, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_LOOP_END",	/* name */
! 	 TRUE,			/* partial_inplace */
! 	 0xff,			/* src_mask */
  	 0xff,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
  
!   EMPTY_HOWTO (38),
!   EMPTY_HOWTO (39),
!   EMPTY_HOWTO (40),
!   EMPTY_HOWTO (41),
!   EMPTY_HOWTO (42),
!   EMPTY_HOWTO (43),
!   EMPTY_HOWTO (44),
  
  #ifdef INCLUDE_SHMEDIA
--- 543,678 ----
  	 0,			/* bitpos */
  	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8UL",		/* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0xff,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_DIR8UW,		/* type */
! 	 1,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8UW",		/* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0xff,			/* dst_mask */
  	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_DIR8U,		/* type */
  	 0,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8U",		/* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0xff,			/* dst_mask */
  	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_DIR8SW,		/* type */
  	 1,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8SW",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
  	 0xff,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_DIR8S,		/* type */
! 	 0,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8S",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
  	 0xff,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_DIR4UL,		/* type */
! 	 2,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 4,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR4UL",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_DIR4UW,		/* type */
! 	 1,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 4,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR4UW",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_DIR4U,		/* type */
! 	 0,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 4,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR4U",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_PSHA,		/* type */
! 	 0,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 7,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 4,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_PSHA",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_PSHL,		/* type */
! 	 0,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 7,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 4,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_PSHL",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
  
  #ifdef INCLUDE_SHMEDIA
*************** static reloc_howto_type sh_elf_howto_tab
*** 637,641 ****
  
    EMPTY_HOWTO (52),
!   EMPTY_HOWTO (53),
    EMPTY_HOWTO (54),
    EMPTY_HOWTO (55),
--- 793,811 ----
  
    EMPTY_HOWTO (52),
! 
!   HOWTO (R_SH_DIR16S,		/* type */
! 	 0,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 16,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR16S",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0xffff,		/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
    EMPTY_HOWTO (54),
    EMPTY_HOWTO (55),
*************** static const struct elf_reloc_map sh_rel
*** 1862,1865 ****
--- 2032,2037 ----
    { BFD_RELOC_NONE, R_SH_NONE },
    { BFD_RELOC_32, R_SH_DIR32 },
+   { BFD_RELOC_16, R_SH_DIR16 },
+   { BFD_RELOC_8, R_SH_DIR8 },
    { BFD_RELOC_CTOR, R_SH_DIR32 },
    { BFD_RELOC_32_PCREL, R_SH_REL32 },
*************** sh_elf_relocate_section (bfd *output_bfd
*** 4547,4552 ****
        /* Many of the relocs are only used for relaxing, and are
  	 handled entirely by the relaxation code.  */
!       if (r_type > (int) R_SH_LAST_INVALID_RELOC
! 	  && r_type < (int) R_SH_LOOP_START)
  	continue;
        if (r_type == (int) R_SH_NONE)
--- 4719,4727 ----
        /* Many of the relocs are only used for relaxing, and are
  	 handled entirely by the relaxation code.  */
!       if (r_type >= (int) R_SH_SWITCH16
! 	  && r_type <= (int) R_SH_LABEL)
! 	continue;
!       if (r_type >= (int) R_SH_SWITCH8
! 	  && r_type <= (int) R_SH_GNU_VTINHERIT)
  	continue;
        if (r_type == (int) R_SH_NONE)
*************** sh_elf_relocate_section (bfd *output_bfd
*** 4840,4843 ****
--- 5015,5082 ----
  	  bfd_set_error (bfd_error_bad_value);
  	  return FALSE;
+ 
+ 	case R_SH_DIR16:
+ 	case R_SH_DIR8:
+ 	case R_SH_DIR8U:
+ 	case R_SH_DIR8S:
+ 	case R_SH_DIR4U:
+ 	  goto final_link_relocate;
+ 
+ 	case R_SH_DIR8UL:
+ 	case R_SH_DIR4UL:
+ 	  if (relocation & 3)
+ 	    {
+ 	      ((*_bfd_error_handler)
+ 	       (_("%s: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+ 		bfd_archive_filename (input_section->owner),
+ 		(unsigned long) rel->r_offset, howto->name, 
+ 		(unsigned long)relocation));
+ 	      bfd_set_error (bfd_error_bad_value);
+ 	      return FALSE;
+ 	    }
+ 	  goto final_link_relocate;
+ 
+ 	case R_SH_DIR8UW:
+ 	case R_SH_DIR8SW:
+ 	case R_SH_DIR4UW:
+ 	  if (relocation & 1)
+ 	    {
+ 	      ((*_bfd_error_handler)
+ 	       (_("%s: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+ 		bfd_archive_filename (input_section->owner),
+ 		(unsigned long) rel->r_offset, howto->name, 
+ 		(unsigned long)relocation));
+ 	      bfd_set_error (bfd_error_bad_value);
+ 	      return FALSE;
+ 	    }
+ 	  goto final_link_relocate;
+ 
+ 	case R_SH_PSHA:
+ 	  if ((signed int)relocation < -32
+ 	      || (signed int)relocation > 32)
+ 	    {
+ 	      ((*_bfd_error_handler)
+ 	       (_("%s: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"),
+ 		bfd_archive_filename (input_section->owner),
+ 		(unsigned long) rel->r_offset,
+ 		(unsigned long)relocation));
+ 	      bfd_set_error (bfd_error_bad_value);
+ 	      return FALSE;
+ 	    }
+ 	  goto final_link_relocate;
+ 
+ 	case R_SH_PSHL:
+ 	  if ((signed int)relocation < -16
+ 	      || (signed int)relocation > 16)
+ 	    {
+ 	      ((*_bfd_error_handler)
+ 	       (_("%s: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"),
+ 		bfd_archive_filename (input_section->owner),
+ 		(unsigned long) rel->r_offset,
+ 		(unsigned long)relocation));
+ 	      bfd_set_error (bfd_error_bad_value);
+ 	      return FALSE;
+ 	    }
+ 	  goto final_link_relocate;
  
  	case R_SH_DIR32:

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-08-15 20:51 [patch] new sh relocs DJ Delorie
@ 2003-08-16  5:19 ` Ian Lance Taylor
  2003-08-16 13:38   ` DJ Delorie
  0 siblings, 1 reply; 13+ messages in thread
From: Ian Lance Taylor @ 2003-08-16  5:19 UTC (permalink / raw)
  To: DJ Delorie; +Cc: binutils

DJ Delorie <dj@redhat.com> writes:

> Renesas has asked us to implement more of the "official" relocations.
> Unfortunately, we had some GNU reloc extensions in those numbers, so I
> had to move some of them to the reserved slots.  Note that nearly all
> reloc values from 1 to 127 are used by SH, so we should expect more of
> this type of thing in the future.  They also define bit 7 of the type
> to mean something, so in reality, they've used up all the relocations.

But, but, isn't moving relocs going to break existing object files?

Ian

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-08-16  5:19 ` Ian Lance Taylor
@ 2003-08-16 13:38   ` DJ Delorie
  2003-08-16 13:55     ` Alan Modra
  0 siblings, 1 reply; 13+ messages in thread
From: DJ Delorie @ 2003-08-16 13:38 UTC (permalink / raw)
  To: ian; +Cc: binutils


> But, but, isn't moving relocs going to break existing object files?

Sad but true.  At least it's only objects built with relax on.
Renesas noted such incompatibility in their request to us.

Note that there are a lot of other relocs that may need to be moved
later, too.  The ones I'm moving now are the ones that conflict with
relocs their compiler currently uses.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-08-16 13:38   ` DJ Delorie
@ 2003-08-16 13:55     ` Alan Modra
  2003-08-16 14:04       ` DJ Delorie
  2003-08-16 15:21       ` Alexandre Oliva
  0 siblings, 2 replies; 13+ messages in thread
From: Alan Modra @ 2003-08-16 13:55 UTC (permalink / raw)
  To: DJ Delorie; +Cc: ian, binutils

On Sat, Aug 16, 2003 at 09:38:45AM -0400, DJ Delorie wrote:
> 
> > But, but, isn't moving relocs going to break existing object files?
> 
> Sad but true.  At least it's only objects built with relax on.
> Renesas noted such incompatibility in their request to us.

You need to reject old objects then.  EI_OSABI and EI_ABIVERSION were
designed for exactly this purpose.

> Note that there are a lot of other relocs that may need to be moved
> later, too.  The ones I'm moving now are the ones that conflict with
> relocs their compiler currently uses.

Better to move them all now if you can.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-08-16 13:55     ` Alan Modra
@ 2003-08-16 14:04       ` DJ Delorie
  2003-08-16 15:21         ` Alexandre Oliva
  2003-08-16 15:21       ` Alexandre Oliva
  1 sibling, 1 reply; 13+ messages in thread
From: DJ Delorie @ 2003-08-16 14:04 UTC (permalink / raw)
  To: amodra; +Cc: ian, binutils


> You need to reject old objects then.  EI_OSABI and EI_ABIVERSION were
> designed for exactly this purpose.

Ok.

> Better to move them all now if you can.

Where?  The Renesas ABI defines *all* the available relocs, except the
few slots where the relax ones are now.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-08-16 14:04       ` DJ Delorie
@ 2003-08-16 15:21         ` Alexandre Oliva
  0 siblings, 0 replies; 13+ messages in thread
From: Alexandre Oliva @ 2003-08-16 15:21 UTC (permalink / raw)
  To: DJ Delorie; +Cc: amodra, ian, binutils

On Aug 16, 2003, DJ Delorie <dj@delorie.com> wrote:

>> Better to move them all now if you can.

> Where?  The Renesas ABI defines *all* the available relocs, except the
> few slots where the relax ones are now.

They have a number of slots left in reserved portions, and they said
they'd give us numbers of these relocs.  We just have to ask them for
the official numbers.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-08-16 13:55     ` Alan Modra
  2003-08-16 14:04       ` DJ Delorie
@ 2003-08-16 15:21       ` Alexandre Oliva
  2003-08-25 18:37         ` DJ Delorie
  2003-09-06  0:07         ` DJ Delorie
  1 sibling, 2 replies; 13+ messages in thread
From: Alexandre Oliva @ 2003-08-16 15:21 UTC (permalink / raw)
  To: Alan Modra; +Cc: DJ Delorie, ian, binutils

On Aug 16, 2003, Alan Modra <amodra@bigpond.net.au> wrote:

> On Sat, Aug 16, 2003 at 09:38:45AM -0400, DJ Delorie wrote:
>> 
>> > But, but, isn't moving relocs going to break existing object files?
>> 
>> Sad but true.  At least it's only objects built with relax on.
>> Renesas noted such incompatibility in their request to us.

> You need to reject old objects then.  EI_OSABI and EI_ABIVERSION were
> designed for exactly this purpose.

Unfortunately we're the ones that got the ABI wrong, and Renesas tools
don't emit any EI_* markers we could use to tell, so we should just
take the risk and change the meaning of relocs we've been generating
with the wrong meaning.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-08-16 15:21       ` Alexandre Oliva
@ 2003-08-25 18:37         ` DJ Delorie
  2003-09-06  0:07         ` DJ Delorie
  1 sibling, 0 replies; 13+ messages in thread
From: DJ Delorie @ 2003-08-25 18:37 UTC (permalink / raw)
  To: binutils


Ok, so what do I do with this patch?  It seems that the only objection
is that it's not backwards compatible, but since we're doing this to
link against SHC-built objects we can't do anything about that anyway.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-08-16 15:21       ` Alexandre Oliva
  2003-08-25 18:37         ` DJ Delorie
@ 2003-09-06  0:07         ` DJ Delorie
  2003-09-06  6:59           ` Nick Clifton
  2003-09-10  7:56           ` Alexandre Oliva
  1 sibling, 2 replies; 13+ messages in thread
From: DJ Delorie @ 2003-09-06  0:07 UTC (permalink / raw)
  To: aoliva; +Cc: amodra, ian, binutils


> Unfortunately we're the ones that got the ABI wrong, and Renesas tools
> don't emit any EI_* markers we could use to tell, so we should just
> take the risk and change the meaning of relocs we've been generating
> with the wrong meaning.

So where are we on this patch?  Can I commit it, or what?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-09-06  0:07         ` DJ Delorie
@ 2003-09-06  6:59           ` Nick Clifton
  2003-09-10  7:56           ` Alexandre Oliva
  1 sibling, 0 replies; 13+ messages in thread
From: Nick Clifton @ 2003-09-06  6:59 UTC (permalink / raw)
  To: DJ Delorie; +Cc: aoliva, amodra, ian, binutils

Hi DJ,

>> Unfortunately we're the ones that got the ABI wrong, and Renesas tools
>> don't emit any EI_* markers we could use to tell, so we should just
>> take the risk and change the meaning of relocs we've been generating
>> with the wrong meaning.
>
> So where are we on this patch?  Can I commit it, or what?

Well, if you have not heard from any of the official SH port
maintainers by lets say, Tuesday, then please go ahead an commit the
patch.

Cheers
        Nick
        

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-09-06  0:07         ` DJ Delorie
  2003-09-06  6:59           ` Nick Clifton
@ 2003-09-10  7:56           ` Alexandre Oliva
  2003-09-10 16:45             ` DJ Delorie
  2003-09-24  2:28             ` DJ Delorie
  1 sibling, 2 replies; 13+ messages in thread
From: Alexandre Oliva @ 2003-09-10  7:56 UTC (permalink / raw)
  To: DJ Delorie; +Cc: amodra, ian, binutils

On Sep  5, 2003, DJ Delorie <dj@redhat.com> wrote:

>> Unfortunately we're the ones that got the ABI wrong, and Renesas tools
>> don't emit any EI_* markers we could use to tell, so we should just
>> take the risk and change the meaning of relocs we've been generating
>> with the wrong meaning.

> So where are we on this patch?  Can I commit it, or what?

Since Renesas pretty much told us to decide which numbers to use
within the 0xa-0x20 reserved range, here are the changes I'd like us
to make:

33 (0x21)  R_SH_SWITCH8  =>  move to 0x18, just before R_SH_SWITCH16

34 (0x22)  R_SH_GNU_VTINHERIT  => remove
35 (0x23)  R_SH_GNU_VTENTRY    => remove

The C++ vtable GCing feature has been removed from GCC, there's no
point in allocating official relocs (or using using relocs from our
reserved range) for this purpose.


36 (0x24)  R_SH_LOOP_START => move to 0x16 or 0xa, your call

37 (0x25)  R_SH_LOOP_END => move to 0x17 or 0xb, your call

I used to like 0x16 and 0x17 better, but now I'm thinking using 0xa
and 0xb for GNU extensions would more clearly mark the region reserved
for us.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-09-10  7:56           ` Alexandre Oliva
@ 2003-09-10 16:45             ` DJ Delorie
  2003-09-24  2:28             ` DJ Delorie
  1 sibling, 0 replies; 13+ messages in thread
From: DJ Delorie @ 2003-09-10 16:45 UTC (permalink / raw)
  To: aoliva; +Cc: amodra, ian, binutils


> Since Renesas pretty much told us to decide which numbers to use
> within the 0xa-0x20 reserved range, here are the changes I'd like us
> to make:

If you send me a complete reference list of our relocs, I'll make the
changes.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [patch] new sh relocs
  2003-09-10  7:56           ` Alexandre Oliva
  2003-09-10 16:45             ` DJ Delorie
@ 2003-09-24  2:28             ` DJ Delorie
  1 sibling, 0 replies; 13+ messages in thread
From: DJ Delorie @ 2003-09-24  2:28 UTC (permalink / raw)
  To: binutils


Sorry this took so long, but other projects took priority for a while.
Here is the patch as committed.  I left the VT* relocs in for now,
because gas still supports them even though gcc doesn't, so removing
them would be outside the scope of my patch.

Index: bfd/ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.2265
diff -p -2 -r1.2265  bfd/ChangeLog
*** bfd/ChangeLog	23 Sep 2003 20:23:54 -0000	1.2265
--- bfd/ChangeLog	24 Sep 2003 02:27:02 -0000
***************
*** 1,2 ****
--- 1,13 ----
+ 2003-09-23  DJ Delorie  <dj@redhat.com>
+ 
+ 	* elf32-sh.c (sh_elf_howto_table): R_SH_SWITCH8,
+ 	R_SH_GNU_VTINHERIT, R_SH_GNU_VTENTRY,
+ 	R_SH_LOOP_START,R_SH_LOOP_END moved to "reserved" spaces,
+ 	R_SH_DIR16, R_SH_DIR8, R_SH_DIR8UL, R_SH_DIR8UW, R_SH_DIR8U,
+ 	R_SH_DIR8SW, R_SH_DIR8S, R_SH_DIR4UL, R_SH_DIR4UW, R_SH_DIR4U,
+ 	R_SH_PSHA, R_SH_PSHL added.
+ 	(sh_reloc_map): Add R_SH_DIR16 and R_SH_DIR8.
+ 	(sh_elf_relocate_section): Support new relocs.
+ 
  2003-09-23  Bob Wilson  <bob.wilson@acm.org>
  
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.91
diff -p -2 -r1.91  bfd/elf32-sh.c
*** bfd/elf32-sh.c	20 Aug 2003 08:37:17 -0000	1.91
--- bfd/elf32-sh.c	24 Sep 2003 02:27:03 -0000
*************** static reloc_howto_type sh_elf_howto_tab
*** 277,282 ****
  	 TRUE),			/* pcrel_offset */
  
!   EMPTY_HOWTO (10),
!   EMPTY_HOWTO (11),
    EMPTY_HOWTO (12),
    EMPTY_HOWTO (13),
--- 277,310 ----
  	 TRUE),			/* pcrel_offset */
  
!   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
!   HOWTO (R_SH_LOOP_START,	/* type */
! 	 1,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_LOOP_START",	/* name */
! 	 TRUE,			/* partial_inplace */
! 	 0xff,			/* src_mask */
! 	 0xff,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
! 
!   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
!   HOWTO (R_SH_LOOP_END,		/* type */
! 	 1,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_LOOP_END",	/* name */
! 	 TRUE,			/* partial_inplace */
! 	 0xff,			/* src_mask */
! 	 0xff,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
! 
    EMPTY_HOWTO (12),
    EMPTY_HOWTO (13),
*************** static reloc_howto_type sh_elf_howto_tab
*** 289,295 ****
    EMPTY_HOWTO (20),
    EMPTY_HOWTO (21),
-   EMPTY_HOWTO (22),
-   EMPTY_HOWTO (23),
-   EMPTY_HOWTO (24),
  
    /* The remaining relocs are a GNU extension used for relaxing.  The
--- 317,320 ----
*************** static reloc_howto_type sh_elf_howto_tab
*** 298,301 ****
--- 323,373 ----
       relaxation code.  */
  
+   /* GNU extension to record C++ vtable hierarchy */
+   HOWTO (R_SH_GNU_VTINHERIT, /* type */
+ 	 0,			/* rightshift */
+ 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+ 	 0,			/* bitsize */
+ 	 FALSE,			/* pc_relative */
+ 	 0,			/* bitpos */
+ 	 complain_overflow_dont, /* complain_on_overflow */
+ 	 NULL,			/* special_function */
+ 	 "R_SH_GNU_VTINHERIT", /* name */
+ 	 FALSE,			/* partial_inplace */
+ 	 0,			/* src_mask */
+ 	 0,			/* dst_mask */
+ 	 FALSE),		/* pcrel_offset */
+ 
+   /* GNU extension to record C++ vtable member usage */
+   HOWTO (R_SH_GNU_VTENTRY,     /* type */
+ 	 0,			/* rightshift */
+ 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+ 	 0,			/* bitsize */
+ 	 FALSE,			/* pc_relative */
+ 	 0,			/* bitpos */
+ 	 complain_overflow_dont, /* complain_on_overflow */
+ 	 _bfd_elf_rel_vtable_reloc_fn,	/* special_function */
+ 	 "R_SH_GNU_VTENTRY",   /* name */
+ 	 FALSE,			/* partial_inplace */
+ 	 0,			/* src_mask */
+ 	 0,			/* dst_mask */
+ 	 FALSE),		/* pcrel_offset */
+ 
+   /* An 8 bit switch table entry.  This is generated for an expression
+      such as ``.word L1 - L2''.  The offset holds the difference
+      between the reloc address and L2.  */
+   HOWTO (R_SH_SWITCH8,		/* type */
+ 	 0,			/* rightshift */
+ 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+ 	 8,			/* bitsize */
+ 	 FALSE,			/* pc_relative */
+ 	 0,			/* bitpos */
+ 	 complain_overflow_unsigned, /* complain_on_overflow */
+ 	 sh_elf_ignore_reloc,	/* special_function */
+ 	 "R_SH_SWITCH8",	/* name */
+ 	 FALSE,			/* partial_inplace */
+ 	 0,			/* src_mask */
+ 	 0,			/* dst_mask */
+ 	 TRUE),			/* pcrel_offset */
+ 
    /* A 16 bit switch table entry.  This is generated for an expression
       such as ``.word L1 - L2''.  The offset holds the difference
*************** static reloc_howto_type sh_elf_howto_tab
*** 435,442 ****
  	 TRUE),			/* pcrel_offset */
  
!   /* An 8 bit switch table entry.  This is generated for an expression
!      such as ``.word L1 - L2''.  The offset holds the difference
!      between the reloc address and L2.  */
!   HOWTO (R_SH_SWITCH8,		/* type */
  	 0,			/* rightshift */
  	 0,			/* size (0 = byte, 1 = short, 2 = long) */
--- 507,526 ----
  	 TRUE),			/* pcrel_offset */
  
!   /* The next 12 are only supported via linking in SHC-generated objects.  */
!   HOWTO (R_SH_DIR16,		/* type */
! 	 0,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 16,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_dont, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR16",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0xffff,		/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_DIR8,		/* type */
  	 0,			/* rightshift */
  	 0,			/* size (0 = byte, 1 = short, 2 = long) */
*************** static reloc_howto_type sh_elf_howto_tab
*** 444,522 ****
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_SWITCH8",	/* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
  
!   /* GNU extension to record C++ vtable hierarchy */
!   HOWTO (R_SH_GNU_VTINHERIT, /* type */
! 	 0,			/* rightshift */
! 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 0,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
! 	 complain_overflow_dont, /* complain_on_overflow */
! 	 NULL,			/* special_function */
! 	 "R_SH_GNU_VTINHERIT", /* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0,			/* dst_mask */
  	 FALSE),		/* pcrel_offset */
  
!   /* GNU extension to record C++ vtable member usage */
!   HOWTO (R_SH_GNU_VTENTRY,     /* type */
  	 0,			/* rightshift */
! 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 0,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
! 	 complain_overflow_dont, /* complain_on_overflow */
! 	 _bfd_elf_rel_vtable_reloc_fn,	/* special_function */
! 	 "R_SH_GNU_VTENTRY",   /* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0,			/* dst_mask */
  	 FALSE),		/* pcrel_offset */
  
!   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
!   HOWTO (R_SH_LOOP_START,	/* type */
  	 1,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_signed, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_LOOP_START",	/* name */
! 	 TRUE,			/* partial_inplace */
! 	 0xff,			/* src_mask */
  	 0xff,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
  
!   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
!   HOWTO (R_SH_LOOP_END,		/* type */
! 	 1,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_signed, /* complain_on_overflow */
! 	 sh_elf_ignore_reloc,	/* special_function */
! 	 "R_SH_LOOP_END",	/* name */
! 	 TRUE,			/* partial_inplace */
! 	 0xff,			/* src_mask */
  	 0xff,			/* dst_mask */
! 	 TRUE),			/* pcrel_offset */
  
!   EMPTY_HOWTO (38),
!   EMPTY_HOWTO (39),
!   EMPTY_HOWTO (40),
!   EMPTY_HOWTO (41),
!   EMPTY_HOWTO (42),
!   EMPTY_HOWTO (43),
!   EMPTY_HOWTO (44),
  
  #ifdef INCLUDE_SHMEDIA
--- 528,678 ----
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
+ 	 complain_overflow_dont, /* complain_on_overflow */
+ 	 bfd_elf_generic_reloc,	/* special_function */
+ 	 "R_SH_DIR8",		/* name */
+ 	 FALSE,			/* partial_inplace */
+ 	 0,			/* src_mask */
+ 	 0xff,			/* dst_mask */
+ 	 FALSE),		/* pcrel_offset */
+ 
+   HOWTO (R_SH_DIR8UL,		/* type */
+ 	 2,			/* rightshift */
+ 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+ 	 8,			/* bitsize */
+ 	 FALSE,			/* pc_relative */
+ 	 0,			/* bitpos */
  	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8UL",		/* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0xff,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_DIR8UW,		/* type */
! 	 1,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8UW",		/* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0xff,			/* dst_mask */
  	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_DIR8U,		/* type */
  	 0,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8U",		/* name */
  	 FALSE,			/* partial_inplace */
  	 0,			/* src_mask */
! 	 0xff,			/* dst_mask */
  	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_DIR8SW,		/* type */
  	 1,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8SW",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
  	 0xff,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_DIR8S,		/* type */
! 	 0,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
  	 8,			/* bitsize */
  	 FALSE,			/* pc_relative */
  	 0,			/* bitpos */
  	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR8S",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
  	 0xff,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_DIR4UL,		/* type */
! 	 2,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 4,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR4UL",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_DIR4UW,		/* type */
! 	 1,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 4,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR4UW",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_DIR4U,		/* type */
! 	 0,			/* rightshift */
! 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 4,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_unsigned, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR4U",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
!   HOWTO (R_SH_PSHA,		/* type */
! 	 0,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 7,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 4,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_PSHA",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
  
!   HOWTO (R_SH_PSHL,		/* type */
! 	 0,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 7,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 4,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_PSHL",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0x0f,			/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
  
  #ifdef INCLUDE_SHMEDIA
*************** static reloc_howto_type sh_elf_howto_tab
*** 637,641 ****
  
    EMPTY_HOWTO (52),
!   EMPTY_HOWTO (53),
    EMPTY_HOWTO (54),
    EMPTY_HOWTO (55),
--- 793,811 ----
  
    EMPTY_HOWTO (52),
! 
!   HOWTO (R_SH_DIR16S,		/* type */
! 	 0,			/* rightshift */
! 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
! 	 16,			/* bitsize */
! 	 FALSE,			/* pc_relative */
! 	 0,			/* bitpos */
! 	 complain_overflow_signed, /* complain_on_overflow */
! 	 bfd_elf_generic_reloc,	/* special_function */
! 	 "R_SH_DIR16S",		/* name */
! 	 FALSE,			/* partial_inplace */
! 	 0,			/* src_mask */
! 	 0xffff,		/* dst_mask */
! 	 FALSE),		/* pcrel_offset */
! 
    EMPTY_HOWTO (54),
    EMPTY_HOWTO (55),
*************** static const struct elf_reloc_map sh_rel
*** 1862,1865 ****
--- 2032,2037 ----
    { BFD_RELOC_NONE, R_SH_NONE },
    { BFD_RELOC_32, R_SH_DIR32 },
+   { BFD_RELOC_16, R_SH_DIR16 },
+   { BFD_RELOC_8, R_SH_DIR8 },
    { BFD_RELOC_CTOR, R_SH_DIR32 },
    { BFD_RELOC_32_PCREL, R_SH_REL32 },
*************** sh_elf_relocate_section (bfd *output_bfd
*** 4547,4552 ****
        /* Many of the relocs are only used for relaxing, and are
  	 handled entirely by the relaxation code.  */
!       if (r_type > (int) R_SH_LAST_INVALID_RELOC
! 	  && r_type < (int) R_SH_LOOP_START)
  	continue;
        if (r_type == (int) R_SH_NONE)
--- 4719,4724 ----
        /* Many of the relocs are only used for relaxing, and are
  	 handled entirely by the relaxation code.  */
!       if (r_type >= (int) R_SH_GNU_VTINHERIT
! 	  && r_type <= (int) R_SH_LABEL)
  	continue;
        if (r_type == (int) R_SH_NONE)
*************** sh_elf_relocate_section (bfd *output_bfd
*** 4843,4846 ****
--- 5015,5082 ----
  	  bfd_set_error (bfd_error_bad_value);
  	  return FALSE;
+ 
+ 	case R_SH_DIR16:
+ 	case R_SH_DIR8:
+ 	case R_SH_DIR8U:
+ 	case R_SH_DIR8S:
+ 	case R_SH_DIR4U:
+ 	  goto final_link_relocate;
+ 
+ 	case R_SH_DIR8UL:
+ 	case R_SH_DIR4UL:
+ 	  if (relocation & 3)
+ 	    {
+ 	      ((*_bfd_error_handler)
+ 	       (_("%s: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+ 		bfd_archive_filename (input_section->owner),
+ 		(unsigned long) rel->r_offset, howto->name, 
+ 		(unsigned long)relocation));
+ 	      bfd_set_error (bfd_error_bad_value);
+ 	      return FALSE;
+ 	    }
+ 	  goto final_link_relocate;
+ 
+ 	case R_SH_DIR8UW:
+ 	case R_SH_DIR8SW:
+ 	case R_SH_DIR4UW:
+ 	  if (relocation & 1)
+ 	    {
+ 	      ((*_bfd_error_handler)
+ 	       (_("%s: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
+ 		bfd_archive_filename (input_section->owner),
+ 		(unsigned long) rel->r_offset, howto->name, 
+ 		(unsigned long)relocation));
+ 	      bfd_set_error (bfd_error_bad_value);
+ 	      return FALSE;
+ 	    }
+ 	  goto final_link_relocate;
+ 
+ 	case R_SH_PSHA:
+ 	  if ((signed int)relocation < -32
+ 	      || (signed int)relocation > 32)
+ 	    {
+ 	      ((*_bfd_error_handler)
+ 	       (_("%s: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"),
+ 		bfd_archive_filename (input_section->owner),
+ 		(unsigned long) rel->r_offset,
+ 		(unsigned long)relocation));
+ 	      bfd_set_error (bfd_error_bad_value);
+ 	      return FALSE;
+ 	    }
+ 	  goto final_link_relocate;
+ 
+ 	case R_SH_PSHL:
+ 	  if ((signed int)relocation < -16
+ 	      || (signed int)relocation > 16)
+ 	    {
+ 	      ((*_bfd_error_handler)
+ 	       (_("%s: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"),
+ 		bfd_archive_filename (input_section->owner),
+ 		(unsigned long) rel->r_offset,
+ 		(unsigned long)relocation));
+ 	      bfd_set_error (bfd_error_bad_value);
+ 	      return FALSE;
+ 	    }
+ 	  goto final_link_relocate;
  
  	case R_SH_DIR32:
Index: include/elf/ChangeLog
===================================================================
RCS file: /cvs/src/src/include/elf/ChangeLog,v
retrieving revision 1.186
diff -p -2 -r1.186  include/elf/ChangeLog
*** include/elf/ChangeLog	11 Sep 2003 11:20:41 -0000	1.186
--- include/elf/ChangeLog	24 Sep 2003 02:27:03 -0000
***************
*** 1,2 ****
--- 1,10 ----
+ 2003-09-23  DJ Delorie  <dj@redhat.com>
+ 
+ 	* sh.h (R_SH_SWITCH8, R_SH_GNU_VTINHERIT, R_SH_GNU_VTENTRY,
+ 	R_SH_LOOP_START,R_SH_LOOP_END): Move to "reserved" spaces.
+ 	(R_SH_DIR16, R_SH_DIR8, R_SH_DIR8UL, R_SH_DIR8UW, R_SH_DIR8U,
+ 	R_SH_DIR8SW, R_SH_DIR8S, R_SH_DIR4UL, R_SH_DIR4UW, R_SH_DIR4U,
+ 	R_SH_PSHA, R_SH_PSHL): New.
+ 
  2003-09-11  James Cownie <jcownie@etnus.com>
  
Index: include/elf/sh.h
===================================================================
RCS file: /cvs/src/src/include/elf/sh.h,v
retrieving revision 1.14
diff -p -2 -r1.14  include/elf/sh.h
*** include/elf/sh.h	3 Mar 2003 21:03:58 -0000	1.14
--- include/elf/sh.h	24 Sep 2003 02:27:03 -0000
***************
*** 84,89 ****
  
  /* Relocations.  */
! /* Relocations 25ff are GNU extensions.
!    25..33 are used for relaxation and use the same constants as COFF uses.  */
  START_RELOC_NUMBERS (elf_sh_reloc_type)
    RELOC_NUMBER (R_SH_NONE, 0)
--- 84,89 ----
  
  /* Relocations.  */
! /* Relocations 10-32 and 128-255 are GNU extensions.
!    25..32 and 10 are used for relaxation.  */
  START_RELOC_NUMBERS (elf_sh_reloc_type)
    RELOC_NUMBER (R_SH_NONE, 0)
*************** START_RELOC_NUMBERS (elf_sh_reloc_type)
*** 97,102 ****
    RELOC_NUMBER (R_SH_DIR8W, 8)
    RELOC_NUMBER (R_SH_DIR8L, 9)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC, 10)
!   FAKE_RELOC (R_SH_LAST_INVALID_RELOC, 24)
    RELOC_NUMBER (R_SH_SWITCH16, 25)
    RELOC_NUMBER (R_SH_SWITCH32, 26)
--- 97,110 ----
    RELOC_NUMBER (R_SH_DIR8W, 8)
    RELOC_NUMBER (R_SH_DIR8L, 9)
! 
!   RELOC_NUMBER (R_SH_LOOP_START, 10)
!   RELOC_NUMBER (R_SH_LOOP_END, 11)
! 
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC, 12)
!   FAKE_RELOC (R_SH_LAST_INVALID_RELOC, 21)
! 
!   RELOC_NUMBER (R_SH_GNU_VTINHERIT, 22)
!   RELOC_NUMBER (R_SH_GNU_VTENTRY, 23)
!   RELOC_NUMBER (R_SH_SWITCH8, 24)
    RELOC_NUMBER (R_SH_SWITCH16, 25)
    RELOC_NUMBER (R_SH_SWITCH32, 26)
*************** START_RELOC_NUMBERS (elf_sh_reloc_type)
*** 107,117 ****
    RELOC_NUMBER (R_SH_DATA, 31)
    RELOC_NUMBER (R_SH_LABEL, 32)
!   RELOC_NUMBER (R_SH_SWITCH8, 33)
!   RELOC_NUMBER (R_SH_GNU_VTINHERIT, 34)
!   RELOC_NUMBER (R_SH_GNU_VTENTRY, 35)
!   RELOC_NUMBER (R_SH_LOOP_START, 36)
!   RELOC_NUMBER (R_SH_LOOP_END, 37)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_2, 38)
!   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_2, 44)
    RELOC_NUMBER (R_SH_DIR5U, 45)
    RELOC_NUMBER (R_SH_DIR6U, 46)
--- 115,131 ----
    RELOC_NUMBER (R_SH_DATA, 31)
    RELOC_NUMBER (R_SH_LABEL, 32)
! 
!   RELOC_NUMBER (R_SH_DIR16, 33)
!   RELOC_NUMBER (R_SH_DIR8, 34)
!   RELOC_NUMBER (R_SH_DIR8UL, 35)
!   RELOC_NUMBER (R_SH_DIR8UW, 36)
!   RELOC_NUMBER (R_SH_DIR8U, 37)
!   RELOC_NUMBER (R_SH_DIR8SW, 38)
!   RELOC_NUMBER (R_SH_DIR8S, 39)
!   RELOC_NUMBER (R_SH_DIR4UL, 40)
!   RELOC_NUMBER (R_SH_DIR4UW, 41)
!   RELOC_NUMBER (R_SH_DIR4U, 42)
!   RELOC_NUMBER (R_SH_PSHA, 43)
!   RELOC_NUMBER (R_SH_PSHL, 44)
    RELOC_NUMBER (R_SH_DIR5U, 45)
    RELOC_NUMBER (R_SH_DIR6U, 46)
*************** START_RELOC_NUMBERS (elf_sh_reloc_type)
*** 121,125 ****
    RELOC_NUMBER (R_SH_DIR10SL, 50)
    RELOC_NUMBER (R_SH_DIR10SQ, 51)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_3, 52)
    FAKE_RELOC (R_SH_LAST_INVALID_RELOC_3, 143)
    RELOC_NUMBER (R_SH_TLS_GD_32, 144)
--- 135,142 ----
    RELOC_NUMBER (R_SH_DIR10SL, 50)
    RELOC_NUMBER (R_SH_DIR10SQ, 51)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_2, 52)
!   FAKE_RELOC (R_SH_LAST_INVALID_RELOC_2, 52)
!   RELOC_NUMBER (R_SH_DIR16S, 53)
!   FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_3, 54)
    FAKE_RELOC (R_SH_LAST_INVALID_RELOC_3, 143)
    RELOC_NUMBER (R_SH_TLS_GD_32, 144)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2003-09-24  2:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-15 20:51 [patch] new sh relocs DJ Delorie
2003-08-16  5:19 ` Ian Lance Taylor
2003-08-16 13:38   ` DJ Delorie
2003-08-16 13:55     ` Alan Modra
2003-08-16 14:04       ` DJ Delorie
2003-08-16 15:21         ` Alexandre Oliva
2003-08-16 15:21       ` Alexandre Oliva
2003-08-25 18:37         ` DJ Delorie
2003-09-06  0:07         ` DJ Delorie
2003-09-06  6:59           ` Nick Clifton
2003-09-10  7:56           ` Alexandre Oliva
2003-09-10 16:45             ` DJ Delorie
2003-09-24  2:28             ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).