This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [PATCH] Fix ld segfault with -Map -Tdata=xxx (arm-none-symbianelf,and maybe other targets)
- From: Nick Clifton <nickc at redhat dot com>
- To: Julian Brown <julian at codesourcery dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 17 May 2005 15:37:35 +0100
- Subject: Re: [PATCH] Fix ld segfault with -Map -Tdata=xxx (arm-none-symbianelf,and maybe other targets)
- References: <427A6D13.6010602@codesourcery.com>
Hi Julian,
This patch fixes a segfault when -Map is used together with -Tdata=xxx
with ld on arm-none-symbianelf. The crash doesn't occur when -Tdata
isn't used.
OK to apply, or is something more deeply broken here?
Thanks for supplying this patch. I am going to apply a variant of the
patch (see attached) which allows the value for the symbol to be output
into the map file even if its output section is not known.
Note - whilst looking into this bug I also found a place in elf32-arm.c
which relied upon the symbol's section being present so I am including a
fix for that as well.
You are correct however in thinking that there is something else that is
deeply broken. Specifying -Tdata (or -Ttext or -Tbss) should not be
causing this behaviour. I have looked into it for a while but I could
find no obvious cause. This will have to be something to come back to
at a later date.
Cheers
Nick
ld/ChangeLog
2005-05-17 Julian Brown <julian@codesourcery.com>
* ldlang.c (print_assignment): Do not rely upon a valid result
having a section associated with it.
bfd/ChangeLog2005-05-17 Nick Clifton <nickc@redhat.com>
* elf32-arm.c (elf32_arm_final_link_relocate): Gracefully handle
the situation where a symbol's section is not known but a section
relative R_ARM_RELATIVE reloc has to be generated for the Symbian
OS.
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.183
diff -c -3 -p -r1.183 ldlang.c
*** ld/ldlang.c 17 May 2005 14:35:21 -0000 1.183
--- ld/ldlang.c 17 May 2005 14:35:39 -0000
*************** print_assignment (lang_assignment_statem
*** 3219,3225 ****
if (computation_is_valid)
{
! value = result.value + result.section->bfd_section->vma;
minfo ("0x%V", value);
if (is_dot)
--- 3219,3228 ----
if (computation_is_valid)
{
! value = result.value;
!
! if (result.section)
! value += result.section->bfd_section->vma;
minfo ("0x%V", value);
if (is_dot)
*************** print_assignment (lang_assignment_statem
*** 3233,3239 ****
FALSE, FALSE, TRUE);
if (h)
{
! value = h->u.def.value + result.section->bfd_section->vma;
minfo ("[0x%V]", value);
}
--- 3236,3245 ----
FALSE, FALSE, TRUE);
if (h)
{
! value = h->u.def.value;
!
! if (result.section)
! value += result.section->bfd_section->vma;
minfo ("[0x%V]", value);
}
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.38
diff -c -3 -p -r1.38 elf32-arm.c
*** bfd/elf32-arm.c 7 May 2005 13:22:48 -0000 1.38
--- bfd/elf32-arm.c 17 May 2005 14:35:40 -0000
*************** elf32_arm_final_link_relocate (reloc_how
*** 2692,2698 ****
the section symbol as it is convenient. (We
cannot use the symbol given by "h" directly as it
will not appear in the dynamic symbol table.) */
! symbol = elf_section_data (sym_sec->output_section)->dynindx;
BFD_ASSERT (symbol != 0);
}
else
--- 2692,2701 ----
the section symbol as it is convenient. (We
cannot use the symbol given by "h" directly as it
will not appear in the dynamic symbol table.) */
! if (sym_sec)
! symbol = elf_section_data (sym_sec->output_section)->dynindx;
! else
! symbol = elf_section_data (input_section->output_section)->dynindx;
BFD_ASSERT (symbol != 0);
}
else