public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* The ltoff22x relaxation bug on ia64.
@ 2003-03-17 18:47 H. J. Lu
  2003-03-18 21:02 ` [PATCH] Fix " Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: H. J. Lu @ 2003-03-17 18:47 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: rth, binutils

On Mon, Mar 17, 2003 at 09:10:57AM -0800, H. J. Lu wrote:
> 
> There is another ia64 linker bug. I can't build the current
> gcc-3_2-rhl8-branch in CVS using the current binutils on Linux/ia64. I
> got
> 
> ../boehm-gc/.libs/libgcjgc_convenience.a(reclaim.o)(.text+0xd1): In function
> `report_leak':
> /net/gnu/export/gnu/src/gcc-3.2-redhat-8/gcc/boehm-gc/reclaim.c:40: relocation
> truncated to fit: GPREL22 .text
> collect2: ld returned 1 exit status
> make[5]: *** [libgcj.la] Error 1
> make[5]: Leaving directory
> `/export/build/gnu/gcc-3.2-redhat-8/build-ia64-linux/ia64-unknown-linux-gnu/libjava'
> m
> 
> It is a new bug.
> 

The problem is

http://sources.redhat.com/ml/binutils/2003-02/msg00478.html

doesn't take SHF_MERGE into account. The symaddr computed in
elfNN_ia64_relax_section may be different from the one used.


H.J.

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

* [PATCH] Fix ltoff22x relaxation bug on ia64.
  2003-03-17 18:47 The ltoff22x relaxation bug on ia64 H. J. Lu
@ 2003-03-18 21:02 ` Jakub Jelinek
  2003-03-18 22:40   ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2003-03-18 21:02 UTC (permalink / raw)
  To: Richard Henderson, H. J. Lu; +Cc: binutils

On Mon, Mar 17, 2003 at 10:47:49AM -0800, H. J. Lu wrote:
> On Mon, Mar 17, 2003 at 09:10:57AM -0800, H. J. Lu wrote:
> > 
> > There is another ia64 linker bug. I can't build the current
> > gcc-3_2-rhl8-branch in CVS using the current binutils on Linux/ia64. I
> > got
> > 
> > ../boehm-gc/.libs/libgcjgc_convenience.a(reclaim.o)(.text+0xd1): In function
> > `report_leak':
> > /net/gnu/export/gnu/src/gcc-3.2-redhat-8/gcc/boehm-gc/reclaim.c:40: relocation
> > truncated to fit: GPREL22 .text
> > collect2: ld returned 1 exit status
> > make[5]: *** [libgcj.la] Error 1
> > make[5]: Leaving directory
> > `/export/build/gnu/gcc-3.2-redhat-8/build-ia64-linux/ia64-unknown-linux-gnu/libjava'
> > m
> > 
> > It is a new bug.
> > 
> 
> The problem is
> 
> http://sources.redhat.com/ml/binutils/2003-02/msg00478.html
> 
> doesn't take SHF_MERGE into account. The symaddr computed in
> elfNN_ia64_relax_section may be different from the one used.

Simplified testcase below, fixed by following patch.
This patch includes separately posted "[PATCH] Fix bug in ia64 trampoline"
patch, although done differently.
Ok to commit?

2003-03-18  Jakub Jelinek  <jakub@redhat.com>

	* elfxx-ia64.c (elfNN_ia64_relax_section): Handle relaxation
	againt mergeable sections.  Take r_addend into account when caching
	trampolines.

--- bfd/elfxx-ia64.c.jj	2003-03-18 15:18:23.000000000 -0500
+++ bfd/elfxx-ia64.c	2003-03-18 15:47:21.000000000 -0500
@@ -819,6 +819,7 @@ elfNN_ia64_relax_section (abfd, sec, lin
 
 	      tsec = ia64_info->plt_sec;
 	      toff = dyn_i->plt2_offset;
+	      BFD_ASSERT (irel->r_addend == 0);
 	    }
 
 	  /* Can't do anything else with dynamic symbols.  */
@@ -837,10 +838,15 @@ elfNN_ia64_relax_section (abfd, sec, lin
 	    }
 	}
 
-      symaddr = (tsec->output_section->vma
-		 + tsec->output_offset
-		 + toff
-		 + irel->r_addend);
+      if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
+	toff = _bfd_merged_section_offset (abfd, &tsec,
+					   elf_section_data (tsec)->sec_info,
+					   toff + irel->r_addend,
+					   (bfd_vma) 0);
+      else
+	toff += irel->r_addend;
+
+      symaddr = tsec->output_section->vma + tsec->output_offset + toff;
 
       roff = irel->r_offset;
 
cat > a.s <<EOF
        .text
        .globl fn1
fn1:
        addl r15 = @ltoff(foostr), gp;; ld8 r16 = [r15];;
        addl r15 = @ltoff(barstr), gp;; ld8 r16 = [r15];;
        addl r15 = @ltoff(bazstr), gp;; ld8 r16 = [r15];;
        .section .rodata.str1.8, "aMS", @progbits, 1
        .align 8
foostr: .string "foo"
        .align 8
        .globl barstr
barstr: .string "bar"
        .align 8
bazstr: .fill 0x200000-1, 1, 32
        .byte 0
EOF
cat > b.s <<EOF
        .text
        .globl fn2
fn2:
        addl r15 = @ltoffx(foost2), gp;; ld8.mov r16 = [r15], foost2;;
        addl r15 = @ltoffx(barst2), gp;; ld8.mov r16 = [r15], barst2;;
        addl r15 = @ltoffx(bazst2), gp;; ld8.mov r16 = [r15], bazst2;;
        addl r15 = @ltoffx(.Lstr2), gp;; ld8.mov r16 = [r15], .Lstr2;;
        .section .rodata.str1.8, "aMS", @progbits, 1
        .align 8
foost2: .string "foo"
        .align 8
        .globl barst2
barst2: .string "bar"
        .align 8
        .globl bazst2
bazst2: .string "baz"
        .align 8
.Lstr2: .string "str"
        .data
        .globl __gp
__gp:
EOF
as -o a.o a.s
as -o b.o b.s
ld -shared -o a.so a.o b.o

	Jakub

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

* Re: [PATCH] Fix ltoff22x relaxation bug on ia64.
  2003-03-18 21:02 ` [PATCH] Fix " Jakub Jelinek
@ 2003-03-18 22:40   ` Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2003-03-18 22:40 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: H. J. Lu, binutils

On Tue, Mar 18, 2003 at 10:02:53PM +0100, Jakub Jelinek wrote:
> 	* elfxx-ia64.c (elfNN_ia64_relax_section): Handle relaxation
> 	againt mergeable sections.  Take r_addend into account when caching
> 	trampolines.

Ok.

Thanks for fixing this.


r~

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

end of thread, other threads:[~2003-03-18 22:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-17 18:47 The ltoff22x relaxation bug on ia64 H. J. Lu
2003-03-18 21:02 ` [PATCH] Fix " Jakub Jelinek
2003-03-18 22:40   ` Richard Henderson

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).