OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [bfd/] [elf32-rx.c] - Diff between revs 14 and 163

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 14 Rev 163
Line 460... Line 460...
{
{
  Elf_Internal_Shdr *           symtab_hdr;
  Elf_Internal_Shdr *           symtab_hdr;
  struct elf_link_hash_entry ** sym_hashes;
  struct elf_link_hash_entry ** sym_hashes;
  Elf_Internal_Rela *           rel;
  Elf_Internal_Rela *           rel;
  Elf_Internal_Rela *           relend;
  Elf_Internal_Rela *           relend;
 
  bfd_boolean                   pid_mode;
 
  bfd_boolean                   saw_subtract = FALSE;
 
 
 
  if (elf_elfheader (output_bfd)->e_flags & E_FLAG_RX_PID)
 
    pid_mode = TRUE;
 
  else
 
    pid_mode = FALSE;
 
 
  symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
  symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
  sym_hashes = elf_sym_hashes (input_bfd);
  sym_hashes = elf_sym_hashes (input_bfd);
  relend     = relocs + input_section->reloc_count;
  relend     = relocs + input_section->reloc_count;
  for (rel = relocs; rel < relend; rel ++)
  for (rel = relocs; rel < relend; rel ++)
Line 486... Line 493...
      h      = NULL;
      h      = NULL;
      sym    = NULL;
      sym    = NULL;
      sec    = NULL;
      sec    = NULL;
      relocation = 0;
      relocation = 0;
 
 
 
      if (rx_stack_top == 0)
 
        saw_subtract = FALSE;
 
 
      if (r_symndx < symtab_hdr->sh_info)
      if (r_symndx < symtab_hdr->sh_info)
        {
        {
          sym = local_syms + r_symndx;
          sym = local_syms + r_symndx;
          sec = local_sections [r_symndx];
          sec = local_sections [r_symndx];
          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, & sec, rel);
          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, & sec, rel);
Line 551... Line 561...
#define OP(i)      (contents[rel->r_offset + (i)])
#define OP(i)      (contents[rel->r_offset + (i)])
#define WARN_REDHAT(type) \
#define WARN_REDHAT(type) \
      _bfd_error_handler (_("%B:%A: Warning: deprecated Red Hat reloc " type " detected against: %s."), \
      _bfd_error_handler (_("%B:%A: Warning: deprecated Red Hat reloc " type " detected against: %s."), \
      input_bfd, input_section, name)
      input_bfd, input_section, name)
 
 
 
      /* Check for unsafe relocs in PID mode.  These are any relocs where
 
         an absolute address is being computed.  There are special cases
 
         for relocs against symbols that are known to be referenced in
 
         crt0.o before the PID base address register has been initialised.  */
 
#define UNSAFE_FOR_PID                                                  \
 
  do                                                                    \
 
    {                                                                   \
 
      if (pid_mode                                                      \
 
          && sec != NULL                                                \
 
          && sec->flags & SEC_READONLY                                  \
 
          && !(input_section->flags & SEC_DEBUGGING)                    \
 
          && strcmp (name, "__pid_base") != 0                            \
 
          && strcmp (name, "__gp") != 0                                  \
 
          && strcmp (name, "__romdatastart") != 0                        \
 
          && !saw_subtract)                                             \
 
        _bfd_error_handler (_("%B(%A): unsafe PID relocation %s at 0x%08lx (against %s in %s)"), \
 
                            input_bfd, input_section, howto->name,      \
 
                            input_section->output_section->vma + input_section->output_offset + rel->r_offset, \
 
                            name, sec->name);                           \
 
    }                                                                   \
 
  while (0)
 
 
      /* Opcode relocs are always big endian.  Data relocs are bi-endian.  */
      /* Opcode relocs are always big endian.  Data relocs are bi-endian.  */
      switch (r_type)
      switch (r_type)
        {
        {
        case R_RX_NONE:
        case R_RX_NONE:
          break;
          break;
Line 571... Line 603...
 
 
        case R_RX_RH_8_NEG:
        case R_RX_RH_8_NEG:
          WARN_REDHAT ("RX_RH_8_NEG");
          WARN_REDHAT ("RX_RH_8_NEG");
          relocation = - relocation;
          relocation = - relocation;
        case R_RX_DIR8S_PCREL:
        case R_RX_DIR8S_PCREL:
 
          UNSAFE_FOR_PID;
          RANGE (-128, 127);
          RANGE (-128, 127);
          OP (0) = relocation;
          OP (0) = relocation;
          break;
          break;
 
 
        case R_RX_DIR8S:
        case R_RX_DIR8S:
 
          UNSAFE_FOR_PID;
          RANGE (-128, 255);
          RANGE (-128, 255);
          OP (0) = relocation;
          OP (0) = relocation;
          break;
          break;
 
 
        case R_RX_DIR8U:
        case R_RX_DIR8U:
 
          UNSAFE_FOR_PID;
          RANGE (0, 255);
          RANGE (0, 255);
          OP (0) = relocation;
          OP (0) = relocation;
          break;
          break;
 
 
        case R_RX_RH_16_NEG:
        case R_RX_RH_16_NEG:
          WARN_REDHAT ("RX_RH_16_NEG");
          WARN_REDHAT ("RX_RH_16_NEG");
          relocation = - relocation;
          relocation = - relocation;
        case R_RX_DIR16S_PCREL:
        case R_RX_DIR16S_PCREL:
 
          UNSAFE_FOR_PID;
          RANGE (-32768, 32767);
          RANGE (-32768, 32767);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
#else
#else
          OP (0) = relocation;
          OP (0) = relocation;
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#endif
#endif
          break;
          break;
 
 
        case R_RX_RH_16_OP:
        case R_RX_RH_16_OP:
          WARN_REDHAT ("RX_RH_16_OP");
          WARN_REDHAT ("RX_RH_16_OP");
 
          UNSAFE_FOR_PID;
          RANGE (-32768, 32767);
          RANGE (-32768, 32767);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (1) = relocation;
          OP (1) = relocation;
          OP (0) = relocation >> 8;
          OP (0) = relocation >> 8;
#else
#else
Line 610... Line 647...
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#endif
#endif
          break;
          break;
 
 
        case R_RX_DIR16S:
        case R_RX_DIR16S:
 
          UNSAFE_FOR_PID;
          RANGE (-32768, 65535);
          RANGE (-32768, 65535);
          if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
          if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
            {
            {
              OP (1) = relocation;
              OP (1) = relocation;
              OP (0) = relocation >> 8;
              OP (0) = relocation >> 8;
Line 624... Line 662...
              OP (1) = relocation >> 8;
              OP (1) = relocation >> 8;
            }
            }
          break;
          break;
 
 
        case R_RX_DIR16U:
        case R_RX_DIR16U:
 
          UNSAFE_FOR_PID;
          RANGE (0, 65536);
          RANGE (0, 65536);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (1) = relocation;
          OP (1) = relocation;
          OP (0) = relocation >> 8;
          OP (0) = relocation >> 8;
#else
#else
Line 635... Line 674...
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#endif
#endif
          break;
          break;
 
 
        case R_RX_DIR16:
        case R_RX_DIR16:
 
          UNSAFE_FOR_PID;
          RANGE (-32768, 65536);
          RANGE (-32768, 65536);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (1) = relocation;
          OP (1) = relocation;
          OP (0) = relocation >> 8;
          OP (0) = relocation >> 8;
#else
#else
Line 646... Line 686...
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#endif
#endif
          break;
          break;
 
 
        case R_RX_DIR16_REV:
        case R_RX_DIR16_REV:
 
          UNSAFE_FOR_PID;
          RANGE (-32768, 65536);
          RANGE (-32768, 65536);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (0) = relocation;
          OP (0) = relocation;
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#else
#else
Line 663... Line 704...
          OP (0) &= 0xf8;
          OP (0) &= 0xf8;
          OP (0) |= relocation & 0x07;
          OP (0) |= relocation & 0x07;
          break;
          break;
 
 
        case R_RX_RH_24_NEG:
        case R_RX_RH_24_NEG:
 
          UNSAFE_FOR_PID;
          WARN_REDHAT ("RX_RH_24_NEG");
          WARN_REDHAT ("RX_RH_24_NEG");
          relocation = - relocation;
          relocation = - relocation;
        case R_RX_DIR24S_PCREL:
        case R_RX_DIR24S_PCREL:
          RANGE (-0x800000, 0x7fffff);
          RANGE (-0x800000, 0x7fffff);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
Line 679... Line 721...
          OP (2) = relocation >> 16;
          OP (2) = relocation >> 16;
#endif
#endif
          break;
          break;
 
 
        case R_RX_RH_24_OP:
        case R_RX_RH_24_OP:
 
          UNSAFE_FOR_PID;
          WARN_REDHAT ("RX_RH_24_OP");
          WARN_REDHAT ("RX_RH_24_OP");
          RANGE (-0x800000, 0x7fffff);
          RANGE (-0x800000, 0x7fffff);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (2) = relocation;
          OP (2) = relocation;
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
Line 693... Line 736...
          OP (2) = relocation >> 16;
          OP (2) = relocation >> 16;
#endif
#endif
          break;
          break;
 
 
        case R_RX_DIR24S:
        case R_RX_DIR24S:
 
          UNSAFE_FOR_PID;
          RANGE (-0x800000, 0x7fffff);
          RANGE (-0x800000, 0x7fffff);
          if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
          if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
            {
            {
              OP (2) = relocation;
              OP (2) = relocation;
              OP (1) = relocation >> 8;
              OP (1) = relocation >> 8;
Line 709... Line 753...
              OP (2) = relocation >> 16;
              OP (2) = relocation >> 16;
            }
            }
          break;
          break;
 
 
        case R_RX_RH_24_UNS:
        case R_RX_RH_24_UNS:
 
          UNSAFE_FOR_PID;
          WARN_REDHAT ("RX_RH_24_UNS");
          WARN_REDHAT ("RX_RH_24_UNS");
          RANGE (0, 0xffffff);
          RANGE (0, 0xffffff);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (2) = relocation;
          OP (2) = relocation;
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
Line 723... Line 768...
          OP (2) = relocation >> 16;
          OP (2) = relocation >> 16;
#endif
#endif
          break;
          break;
 
 
        case R_RX_RH_32_NEG:
        case R_RX_RH_32_NEG:
 
          UNSAFE_FOR_PID;
          WARN_REDHAT ("RX_RH_32_NEG");
          WARN_REDHAT ("RX_RH_32_NEG");
          relocation = - relocation;
          relocation = - relocation;
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (3) = relocation;
          OP (3) = relocation;
          OP (2) = relocation >> 8;
          OP (2) = relocation >> 8;
Line 739... Line 785...
          OP (3) = relocation >> 24;
          OP (3) = relocation >> 24;
#endif
#endif
          break;
          break;
 
 
        case R_RX_RH_32_OP:
        case R_RX_RH_32_OP:
 
          UNSAFE_FOR_PID;
          WARN_REDHAT ("RX_RH_32_OP");
          WARN_REDHAT ("RX_RH_32_OP");
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (3) = relocation;
          OP (3) = relocation;
          OP (2) = relocation >> 8;
          OP (2) = relocation >> 8;
          OP (1) = relocation >> 16;
          OP (1) = relocation >> 16;
Line 918... Line 965...
          break;
          break;
 
 
          /* Complex reloc handling:  */
          /* Complex reloc handling:  */
 
 
        case R_RX_ABS32:
        case R_RX_ABS32:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (3) = relocation;
          OP (3) = relocation;
          OP (2) = relocation >> 8;
          OP (2) = relocation >> 8;
          OP (1) = relocation >> 16;
          OP (1) = relocation >> 16;
Line 933... Line 981...
          OP (3) = relocation >> 24;
          OP (3) = relocation >> 24;
#endif
#endif
          break;
          break;
 
 
        case R_RX_ABS32_REV:
        case R_RX_ABS32_REV:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (0) = relocation;
          OP (0) = relocation;
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
          OP (2) = relocation >> 16;
          OP (2) = relocation >> 16;
Line 949... Line 998...
#endif
#endif
          break;
          break;
 
 
        case R_RX_ABS24S_PCREL:
        case R_RX_ABS24S_PCREL:
        case R_RX_ABS24S:
        case R_RX_ABS24S:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          RANGE (-0x800000, 0x7fffff);
          RANGE (-0x800000, 0x7fffff);
          if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
          if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
            {
            {
              OP (2) = relocation;
              OP (2) = relocation;
Line 966... Line 1016...
              OP (2) = relocation >> 16;
              OP (2) = relocation >> 16;
            }
            }
          break;
          break;
 
 
        case R_RX_ABS16:
        case R_RX_ABS16:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          RANGE (-32768, 65535);
          RANGE (-32768, 65535);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (1) = relocation;
          OP (1) = relocation;
          OP (0) = relocation >> 8;
          OP (0) = relocation >> 8;
Line 978... Line 1029...
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#endif
#endif
          break;
          break;
 
 
        case R_RX_ABS16_REV:
        case R_RX_ABS16_REV:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          RANGE (-32768, 65535);
          RANGE (-32768, 65535);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (0) = relocation;
          OP (0) = relocation;
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
Line 1006... Line 1058...
              OP (1) = relocation >> 8;
              OP (1) = relocation >> 8;
            }
            }
          break;
          break;
 
 
        case R_RX_ABS16U:
        case R_RX_ABS16U:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          RANGE (0, 65536);
          RANGE (0, 65536);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (1) = relocation;
          OP (1) = relocation;
          OP (0) = relocation >> 8;
          OP (0) = relocation >> 8;
Line 1018... Line 1071...
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#endif
#endif
          break;
          break;
 
 
        case R_RX_ABS16UL:
        case R_RX_ABS16UL:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          relocation >>= 2;
          relocation >>= 2;
          RANGE (0, 65536);
          RANGE (0, 65536);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (1) = relocation;
          OP (1) = relocation;
Line 1031... Line 1085...
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#endif
#endif
          break;
          break;
 
 
        case R_RX_ABS16UW:
        case R_RX_ABS16UW:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          relocation >>= 1;
          relocation >>= 1;
          RANGE (0, 65536);
          RANGE (0, 65536);
#if RX_OPCODE_BIG_ENDIAN
#if RX_OPCODE_BIG_ENDIAN
          OP (1) = relocation;
          OP (1) = relocation;
Line 1044... Line 1099...
          OP (1) = relocation >> 8;
          OP (1) = relocation >> 8;
#endif
#endif
          break;
          break;
 
 
        case R_RX_ABS8:
        case R_RX_ABS8:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          RANGE (-128, 255);
          RANGE (-128, 255);
          OP (0) = relocation;
          OP (0) = relocation;
          break;
          break;
 
 
        case R_RX_ABS8U:
        case R_RX_ABS8U:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          RANGE (0, 255);
          RANGE (0, 255);
          OP (0) = relocation;
          OP (0) = relocation;
          break;
          break;
 
 
        case R_RX_ABS8UL:
        case R_RX_ABS8UL:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          relocation >>= 2;
          relocation >>= 2;
          RANGE (0, 255);
          RANGE (0, 255);
          OP (0) = relocation;
          OP (0) = relocation;
          break;
          break;
 
 
        case R_RX_ABS8UW:
        case R_RX_ABS8UW:
 
          UNSAFE_FOR_PID;
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          relocation >>= 1;
          relocation >>= 1;
          RANGE (0, 255);
          RANGE (0, 255);
          OP (0) = relocation;
          OP (0) = relocation;
          break;
          break;
 
 
        case R_RX_ABS8S_PCREL:
 
        case R_RX_ABS8S:
        case R_RX_ABS8S:
 
          UNSAFE_FOR_PID;
 
        case R_RX_ABS8S_PCREL:
          RX_STACK_POP (relocation);
          RX_STACK_POP (relocation);
          RANGE (-128, 127);
          RANGE (-128, 127);
          OP (0) = relocation;
          OP (0) = relocation;
          break;
          break;
 
 
        case R_RX_SYM:
        case R_RX_SYM:
          if (r_symndx < symtab_hdr->sh_info)
          if (r_symndx < symtab_hdr->sh_info)
            RX_STACK_PUSH (sec->output_section->vma
            RX_STACK_PUSH (sec->output_section->vma
                           + sec->output_offset
                           + sec->output_offset
                           + sym->st_value);
                           + sym->st_value
 
                           + rel->r_addend);
          else
          else
            {
            {
              if (h != NULL
              if (h != NULL
                  && (h->root.type == bfd_link_hash_defined
                  && (h->root.type == bfd_link_hash_defined
                      || h->root.type == bfd_link_hash_defweak))
                      || h->root.type == bfd_link_hash_defweak))
                RX_STACK_PUSH (h->root.u.def.value
                RX_STACK_PUSH (h->root.u.def.value
                               + sec->output_section->vma
                               + sec->output_section->vma
                               + sec->output_offset);
                               + sec->output_offset
 
                               + rel->r_addend);
              else
              else
                _bfd_error_handler (_("Warning: RX_SYM reloc with an unknown symbol"));
                _bfd_error_handler (_("Warning: RX_SYM reloc with an unknown symbol"));
            }
            }
          break;
          break;
 
 
Line 1119... Line 1181...
 
 
        case R_RX_OPsub:
        case R_RX_OPsub:
          {
          {
            int32_t tmp1, tmp2;
            int32_t tmp1, tmp2;
 
 
 
            saw_subtract = TRUE;
            RX_STACK_POP (tmp1);
            RX_STACK_POP (tmp1);
            RX_STACK_POP (tmp2);
            RX_STACK_POP (tmp2);
            tmp2 -= tmp1;
            tmp2 -= tmp1;
            RX_STACK_PUSH (tmp2);
            RX_STACK_PUSH (tmp2);
          }
          }
Line 1141... Line 1204...
 
 
        case R_RX_OPdiv:
        case R_RX_OPdiv:
          {
          {
            int32_t tmp1, tmp2;
            int32_t tmp1, tmp2;
 
 
 
            saw_subtract = TRUE;
            RX_STACK_POP (tmp1);
            RX_STACK_POP (tmp1);
            RX_STACK_POP (tmp2);
            RX_STACK_POP (tmp2);
            tmp1 /= tmp2;
            tmp1 /= tmp2;
            RX_STACK_PUSH (tmp1);
            RX_STACK_PUSH (tmp1);
          }
          }
Line 2891... Line 2955...
      elf_flags_init (obfd) = TRUE;
      elf_flags_init (obfd) = TRUE;
      elf_elfheader (obfd)->e_flags = new_flags;
      elf_elfheader (obfd)->e_flags = new_flags;
    }
    }
  else if (old_flags != new_flags)
  else if (old_flags != new_flags)
    {
    {
      flagword known_flags = E_FLAG_RX_64BIT_DOUBLES | E_FLAG_RX_DSP;
      flagword known_flags = E_FLAG_RX_64BIT_DOUBLES | E_FLAG_RX_DSP | E_FLAG_RX_PID;
 
 
      if ((old_flags ^ new_flags) & known_flags)
      if ((old_flags ^ new_flags) & known_flags)
        {
        {
          /* Only complain if flag bits we care about do not match.
          /* Only complain if flag bits we care about do not match.
             Other bits may be set, since older binaries did use some
             Other bits may be set, since older binaries did use some

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.