[PATCH] force NOSTRIP for .debug_frame on mips-irix
Olivier Hainque
hainque@adacore.com
Thu Oct 25 12:38:00 GMT 2007
Hello,
Attached is a patch to address an issue first discussed on gcc-patches
(http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00414.html), where it was
suggested that a change to GNU as would be more appropriate.
GCC for mips/Irix used to set NOSTRIP bit on .debug_frame and
doesn't any more.
This is causing troubles when using the libexc system library e.g.
for frame unwinding purposes, because it expects a single .debug_frame
per executable, the section has NOSTRIP set in system objects and the
native linker doesn't merge those having the bit set together with
those not having it.
Typically, for
<< /* t.c */
#include <libexc.h>
int main (void)
{
trace_back_stack_and_print ();
return 0;
}
>>
We see
$ gcc -o t t.c -lexc
$ elfdump -hv t | grep -A 1 debug_frame
[37] SHT_MIPS_DWARF 0 0x9bc0 0x4b0 .debug_frame
0 0 0x4 0 0x00000000
--
[39] SHT_MIPS_DWARF 0 0xa5a6 0xa4 .debug_frame
0 0 0x1 0 0x08000000 NOSTRIP
$ ./t
libexc(158601884): FATAL ERROR update_obj_info: dwarf_elf_init failed
for ./t -- (107) DW_DLE_DEBUG_FRAME_DUPLICATE Only one .debug_frame
section is allowed
The attached patch addresses this by teaching gas to set the bit as part
of similar specialized treatments it already performs in other cases.
Tested by checking that the "make check" outputs remain unchanged
after the patch and by checking that the test above now behaves as
expected.
Thanks in advance,
Olivier
2007-10-10 Olivier Hainque <hainque@adacore.com>
* bfd/elfxx-mips.c (_bfd_mips_elf_fake_sections): Force
SHF_MIPS_NOSTRIP on .debug_frame for Irix.
-------------- next part --------------
*** bfd/elfxx-mips.c.ori 2007-10-10 09:28:42.715483416 -0400
--- bfd/elfxx-mips.c 2007-10-10 09:56:46.514369373 -0400
*************** _bfd_mips_elf_fake_sections (bfd *abfd,
*** 5670,5676 ****
hdr->sh_flags |= SHF_MIPS_NOSTRIP;
}
else if (CONST_STRNEQ (name, ".debug_"))
! hdr->sh_type = SHT_MIPS_DWARF;
else if (strcmp (name, ".MIPS.symlib") == 0)
{
hdr->sh_type = SHT_MIPS_SYMBOL_LIB;
--- 5670,5684 ----
hdr->sh_flags |= SHF_MIPS_NOSTRIP;
}
else if (CONST_STRNEQ (name, ".debug_"))
! {
! hdr->sh_type = SHT_MIPS_DWARF;
!
! /* Irix facilities such as libexc expect a single .debug_frame
! per executable, the system ones have NOSTRIP set and the linker
! doesn't merge sections with different flags so ... */
! if (SGI_COMPAT (abfd) && CONST_STRNEQ (name, ".debug_frame"))
! hdr->sh_flags |= SHF_MIPS_NOSTRIP;
! }
else if (strcmp (name, ".MIPS.symlib") == 0)
{
hdr->sh_type = SHT_MIPS_SYMBOL_LIB;
More information about the Binutils
mailing list