Segfault with -pie on IA64
Jim Wilson
wilson@specifixinc.com
Wed Nov 19 01:07:00 GMT 2003
On Sun, 2003-11-16 at 19:26, Alan Modra wrote:
> Actually, it does handle .rela.opd along with any other .rel*, at least
> when you attach the section to the proper bfd.
Thanks for the comments.
My concern with the strip code in size_dynamic_sections is that it was
not clearing ia64_info->rel_fptr_sec like it does for all of the other
related sections. So I added a hunk of code for rel_fptr_sec based on
the code for the other related sections. You are right that it gets
stripped anyways if it is on dynobj.
I also added .rela.opd to the linker script. I put it in
OTHER_PLT_RELOC_SECTIONS as that seemed reasonable to me. If this is
wrong I can fix it.
I have checked in the following patch. This solves the original
testcase from Ian. It was tested on debian testing (sarge) against the
binutils testsuite. There were no regressions.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
-------------- next part --------------
bfd/ChangeLog
2003-11-18 James E Wilson <wilson@specifixinc.com>
* elfxx-ia64.c (get_fptr): For fptr_rel, use dynobj not abfd.
(elfNN_ia64_size_dynamic_sections): When stripping sections, check
for ia64_info->rel_fptr_sec.
ld/ChangeLog
2003-11-18 James E Wilson <wilson@specifixinc.com>
* emulparams/elf64_ia64.sh (OTHER_PLT_RELOC_SECTIONS): Include
.rela.opd if -pie.
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.108
diff -p -r1.108 elfxx-ia64.c
*** bfd/elfxx-ia64.c 5 Nov 2003 13:17:09 -0000 1.108
--- bfd/elfxx-ia64.c 19 Nov 2003 00:10:27 -0000
*************** get_fptr (abfd, info, ia64_info)
*** 1992,2000 ****
if (info->pie)
{
asection *fptr_rel;
! fptr_rel = bfd_make_section(abfd, ".rela.opd");
if (fptr_rel == NULL
! || !bfd_set_section_flags (abfd, fptr_rel,
(SEC_ALLOC | SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
--- 1992,2000 ----
if (info->pie)
{
asection *fptr_rel;
! fptr_rel = bfd_make_section(dynobj, ".rela.opd");
if (fptr_rel == NULL
! || !bfd_set_section_flags (dynobj, fptr_rel,
(SEC_ALLOC | SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
*************** elfNN_ia64_size_dynamic_sections (output
*** 2926,2931 ****
--- 2926,2940 ----
{
if (strip)
ia64_info->fptr_sec = NULL;
+ }
+ else if (sec == ia64_info->rel_fptr_sec)
+ {
+ if (strip)
+ ia64_info->rel_fptr_sec = NULL;
+ else
+ /* We use the reloc_count field as a counter if we need to
+ copy relocs into the output file. */
+ sec->reloc_count = 0;
}
else if (sec == ia64_info->plt_sec)
{
Index: ld/emulparams/elf64_ia64.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf64_ia64.sh,v
retrieving revision 1.13
diff -p -r1.13 elf64_ia64.sh
*** ld/emulparams/elf64_ia64.sh 13 Oct 2003 15:55:51 -0000 1.13
--- ld/emulparams/elf64_ia64.sh 19 Nov 2003 00:28:04 -0000
*************** test -z "$CREATE_PIE" && OTHER_READONLY_
*** 28,33 ****
--- 28,35 ----
.opd ${RELOCATING-0} : { *(.opd) }"
test -n "$CREATE_PIE" && OTHER_READWRITE_SECTIONS="
.opd ${RELOCATING-0} : { *(.opd) }"
+ test -n "$CREATE_PIE" && OTHER_PLT_RELOC_SECTIONS="${OTHER_PLT_RELOC_SECTIONS}
+ .rela.opd ${RELOCATING-0} : { *(.rela.opd) }"
OTHER_READONLY_SECTIONS="${OTHER_READONLY_SECTIONS}
.IA_64.unwind_info ${RELOCATING-0} : { *(.IA_64.unwind_info${RELOCATING+* .gnu.linkonce.ia64unwi.*}) }
.IA_64.unwind ${RELOCATING-0} : { *(.IA_64.unwind${RELOCATING+* .gnu.linkonce.ia64unw.*}) }"
More information about the Binutils
mailing list