* Bug in ia64 trampoline
@ 2003-03-04 6:30 H. J. Lu
2003-03-17 18:27 ` [PATCH] Fix bug " Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: H. J. Lu @ 2003-03-04 6:30 UTC (permalink / raw)
To: binutils
While looking at elfNN_ia64_relax_section, I don't see how it can reuse the
trampoline without checking r_addend. The relaxation code creates a trampoline
and reuse the old relocation by modifying r_info and r_offset
irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
R_IA64_PCREL60B);
irel->r_offset = trampoff + 2;
A relocation will be applied at the trampoline with r_addend. When it cherks a
trampoline can be reuse, it doesn't check r_addend at all. Did I miss
something?
H.J.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] Fix bug in ia64 trampoline
2003-03-04 6:30 Bug in ia64 trampoline H. J. Lu
@ 2003-03-17 18:27 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2003-03-17 18:27 UTC (permalink / raw)
To: H. J. Lu, rth; +Cc: binutils
On Mon, Mar 03, 2003 at 10:30:18PM -0800, H. J. Lu wrote:
> While looking at elfNN_ia64_relax_section, I don't see how it can reuse the
> trampoline without checking r_addend. The relaxation code creates a trampoline
> and reuse the old relocation by modifying r_info and r_offset
>
> irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
> R_IA64_PCREL60B);
> irel->r_offset = trampoff + 2;
>
> A relocation will be applied at the trampoline with r_addend. When it cherks a
> trampoline can be reuse, it doesn't check r_addend at all. Did I miss
> something?
I agree the code has to take r_addend into account and verified it
on a testcase. The IA-64 backend enforces r_addend == 0 in case of a
branch to PLT with assert elsewhere, so I've just added it
into relax_section too.
cat > test.s <<EOF
.text
.align 16
.global test#
.proc test#
test:
br.call.sptk.many b0 = foo#;;
br.call.sptk.many b0 = bar#;;
br.call.sptk.many b0 = foo# + 16;;
br.call.sptk.many b0 = bar# + 16;;
.endp test#
.section .text.a,"ax",@progbits
.fill 0x1000000, 1, 32
.section .text.b,"ax",@progbits
.align 16
.global foo#
.hidden foo
.proc foo#
foo:
br.ret.sptk.many b0
.endp foo#
.align 16
.global bar#
.hidden bar
.proc bar#
bar:
br.ret.sptk.many b0;;
br.ret.sptk.many b0
.endp bar#
EOF
as -x -o test.o test.s
ld -shared -o test.so test.o
Ok to commit?
2003-03-17 Jakub Jelinek <jakub@redhat.com>
* elfxx-ia64.c (elfNN_ia64_relax_section): Take r_addend into
account when creating trampolines.
--- bfd/elfxx-ia64.c.jj 2003-03-17 07:02:18.000000000 -0500
+++ bfd/elfxx-ia64.c 2003-03-17 12:57:52.000000000 -0500
@@ -790,7 +790,7 @@ elfNN_ia64_relax_section (abfd, sec, lin
else
tsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
- toff = isym->st_value;
+ toff = isym->st_value + irel->r_addend;
dyn_i = get_dyn_sym_info (ia64_info, NULL, abfd, irel, FALSE);
}
else
@@ -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. */
@@ -833,14 +834,13 @@ elfNN_ia64_relax_section (abfd, sec, lin
continue;
tsec = h->root.u.def.section;
- toff = h->root.u.def.value;
+ toff = h->root.u.def.value + irel->r_addend;
}
}
symaddr = (tsec->output_section->vma
+ tsec->output_offset
- + toff
- + irel->r_addend);
+ + toff);
roff = irel->r_offset;
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-17 18:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-04 6:30 Bug in ia64 trampoline H. J. Lu
2003-03-17 18:27 ` [PATCH] Fix bug " Jakub Jelinek
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).