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] Fix ltoff22x relaxation bug on ia64.


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 at redhat dot 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


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