This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] was: MIPS assembler no longer "combines symbols in differentsegments"...


David Daney wrote:
A recent change to gas seems to have broken it so that it no longer works with gcc-3.3. Configured as target=mipsel-linux

The .eh_frame code generated by gcc-3.3 contains things like this:

.4byte $LFB2-.

Where '$LFB2' is in .text and '.' is in .eh_frame. This worked well in 2.15 but for:

$ mipsel-linux-as --version
GNU assembler 050218 20050218

I am getting:

Error: operation combines symbols in different segments

for this.

Is there a good reason that this was changed?

If not can we change it back?

There are enough ld bugs in 2.15 that I want to use this snapshot, but I will probably have to resolve this issue first.

David Daney.


Attached is a patch that fixes this problem. This one I am much more confident of. It passes make check in libffi for my hacked up back ported to gcc-3.4.3 version. This include the exception test that failed with my last patch.

make -k check with no regressions. Oddly enough for me this fixes one ld XFAIL even though I am only fixing gas.

I think my copyright things are in order for binutils, but I don't think I have CVS write access for binutils so someone else will have to commit for me.


2005-02-35 David Daney <ddaney@avtrex.com>


        * config/tc-mips.h: #define DIFF_EXPR_OK.
        * config/tc-mips.c (md_apply_fix3): Remove assert (!fixP->fx_pcrel)
        because DIFF_EXPR_OK generates them.
        (tc_gen_reloc) : Handle fixP->fx_pcrel for BFD_RELOC_32 case.


David Daney.
diff -rcp --exclude='*.info*' binutils_reference/binutils-050218/gas/config/tc-mips.c binutils-050218/gas/config/tc-mips.c
*** binutils_reference/binutils-050218/gas/config/tc-mips.c	2005-02-17 05:46:04.000000000 -0800
--- binutils-050218/gas/config/tc-mips.c	2005-02-25 18:46:55.277082758 -0800
*************** md_apply_fix3 (fixS *fixP, valueT *valP,
*** 11018,11025 ****
  
    buf = (bfd_byte *) (fixP->fx_frag->fr_literal + fixP->fx_where);
  
-   assert (! fixP->fx_pcrel);
- 
    /* Don't treat parts of a composite relocation as done.  There are two
       reasons for this:
  
--- 11018,11023 ----
*************** md_apply_fix3 (fixS *fixP, valueT *valP,
*** 11065,11071 ****
      case BFD_RELOC_MIPS16_GPREL:
      case BFD_RELOC_MIPS16_HI16:
      case BFD_RELOC_MIPS16_HI16_S:
-       assert (! fixP->fx_pcrel);
        /* Nothing needed to do. The value comes from the reloc entry */
        break;
  
--- 11063,11068 ----
*************** tc_gen_reloc (asection *section ATTRIBUT
*** 12846,12853 ****
    *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
    reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
  
!   assert (! fixp->fx_pcrel);
!   reloc->addend = fixp->fx_addnumber;
  
    /* Since the old MIPS ELF ABI uses Rel instead of Rela, encode the vtable
       entry to be used in the relocation's section offset.  */
--- 12843,12865 ----
    *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
    reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
  
!   if (fixp->fx_pcrel)
!     {
!       if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
! 	{
! 	  /* At this point, fx_addnumber is "symbol offset - reloc->address".
! 	     Relocations want only the symbol offset.  */
! 	  reloc->addend = fixp->fx_addnumber + reloc->address;
! 	}
!       else
! 	{
! 	  /* A gruesome hack which is a result of the gruesome gas reloc
! 	     handling.  */
! 	  reloc->addend = reloc->address;
! 	}
!     }
!   else
!     reloc->addend = fixp->fx_addnumber;
  
    /* Since the old MIPS ELF ABI uses Rel instead of Rela, encode the vtable
       entry to be used in the relocation's section offset.  */
*************** tc_gen_reloc (asection *section ATTRIBUT
*** 12858,12863 ****
--- 12870,12885 ----
      }
  
    code = fixp->fx_r_type;
+   if (fixp->fx_pcrel)
+     {
+       if (code == BFD_RELOC_32)
+         code = BFD_RELOC_32_PCREL;
+       else
+         as_bad_where (fixp->fx_file, fixp->fx_line,
+ 		     _("Cannot make %s relocation PC relative"),
+ 		     bfd_get_reloc_code_name (code));
+     }
+   
  
    /* To support a PC relative reloc, we used a Cygnus extension.
       We check for that here to make sure that we don't let such a
Only in binutils-050218/gas/config: tc-mips.c~
diff -rcp --exclude='*.info*' binutils_reference/binutils-050218/gas/config/tc-mips.h binutils-050218/gas/config/tc-mips.h
*** binutils_reference/binutils-050218/gas/config/tc-mips.h	2004-04-28 22:14:22.000000000 -0700
--- binutils-050218/gas/config/tc-mips.h	2005-02-25 15:52:23.000000000 -0800
*************** extern void mips_handle_align (struct fr
*** 58,63 ****
--- 58,68 ----
  
  #define MAX_MEM_FOR_RS_ALIGN_CODE  (1 + 2)
  
+ /* We permit PC relative difference expressions because gcc used to
+    generate them in .eh_frame sections.  */
+ #define DIFF_EXPR_OK
+ 
+ 
  /* Tell assembler that we have an itbl_mips.h header file to include.  */
  #define HAVE_ITBL_CPU
  
Only in binutils-050218/gas/config: tc-mips.h~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]