public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: David Daney <ddaney@avtrex.com>
To: binutils@sources.redhat.com
Subject: [Patch] was: MIPS assembler  no longer "combines symbols in different segments"...
Date: Sun, 27 Feb 2005 02:47:00 -0000	[thread overview]
Message-ID: <421FE7A6.7020500@avtrex.com> (raw)
In-Reply-To: <421FAE77.8010206@avtrex.com>

[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]

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.

[-- Attachment #2: binutils.diff --]
[-- Type: text/plain, Size: 3475 bytes --]

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~

  parent reply	other threads:[~2005-02-26  3:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-26 19:36 David Daney
2005-02-26 20:19 ` David Daney
2005-02-27  0:09   ` cgd
2005-02-27  1:17   ` David Daney
2005-02-27  2:47 ` David Daney [this message]
     [not found]   ` <mailpost.1109387217.12843@news-sj1-1>
2005-02-28  9:07     ` [Patch] was: " cgd
2005-02-28 16:30   ` Maciej W. Rozycki
2005-02-28 17:15     ` Daniel Jacobowitz
2005-02-28 18:06       ` Dave Korn
2005-02-28 19:00         ` Maciej W. Rozycki
2005-02-28 19:52           ` David Daney
2005-02-28 20:41             ` Maciej W. Rozycki
2005-02-28 20:53               ` David Daney
2005-02-28 22:03                 ` Maciej W. Rozycki
2005-02-28 22:29                   ` David Daney
2005-02-28 23:00                 ` Richard Sandiford
2005-02-28 19:57           ` Dave Korn
2005-02-28 18:36       ` Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=421FE7A6.7020500@avtrex.com \
    --to=ddaney@avtrex.com \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).