Re: [Mingw-users] unresolved return address in dwarf2 FDE
- Date: Tue, 08 Jan 2008 18:17:34 +1300
- From: Danny Smith <dannysmith@xxxxxxxxxxxx>
- Subject: Re: [Mingw-users] unresolved return address in dwarf2 FDE
> -----Original Message-----
> From: mingw-users-bounces@xxxxxxxxxxxxxxxxxxxxx
> [mailto:mingw-users-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf
> Of Takashi Ono
> Sent: Sunday, 6 January 2008 4:17 a.m.
> To: MinGW Users List
> Cc: Danny Smith
> Subject: Re: [Mingw-users] unresolved return address in dwarf2 FDE
>
>
> Hi,
>
> I have made a patch by myself to avoid harmful reloc's.
Thank you. Would you mind submitting this to binutils list
<binutils@xxxxxxxxxxxxxx>
with a ChangeLog entry?
You will need to provide the testcase as well as an expalnation of why
the undefined weak symbols also need to be excluded.
Thanks again for the bug report and the patch.
Danny
>
> --- ld/pe-dll.c.orig 2006-01-19 14:00:44.000000000 +0900
> +++ ld/pe-dll.c 2008-01-05 23:39:40.891375000 +0900
> @@ -1162,6 +1162,18 @@
> {
> struct bfd_symbol *sym = *relocs[i]->sym_ptr_ptr;
> printf ("rel: %s\n", sym->name);
> + int sym_section_flags = bfd_get_section_flags
> (sym->section->owner,
> sym->section);
> + if (sym_section_flags & SEC_LINK_ONCE
> + && sym->section->output_section ==
> bfd_abs_section_ptr
> + && sym->flags == BSF_LOCAL)
> + printf ("discarded\n");
> + if (sym->flags == BSF_WEAK)
> + {
> + struct bfd_link_hash_entry *blhe =
> bfd_link_hash_lookup (info->
> hash, sym->name,
> +
> FALSE,
> FALSE, FALSE);
> + if (!blhe || blhe->type != bfd_link_hash_defined)
> + printf ("undefined\n");
> + }
> }
> if (!relocs[i]->howto->pc_relative
> && relocs[i]->howto->type !=
> pe_details->imagebase_reloc)
> @@ -1169,6 +1179,19 @@
> bfd_vma sym_vma;
> struct bfd_symbol *sym = *relocs[i]->sym_ptr_ptr;
>
> + int sym_section_flags = bfd_get_section_flags
> (sym->section->owner,
> sym->section);
> + if (sym_section_flags & SEC_LINK_ONCE
> + && sym->section->output_section ==
> bfd_abs_section_ptr
> + && sym->flags == BSF_LOCAL)
> + continue;
> + if (sym->flags == BSF_WEAK)
> + {
> + struct bfd_link_hash_entry *blhe =
> bfd_link_hash_lookup (info->
> hash, sym->name,
> +
> FALSE,
> FALSE, FALSE);
> + if (!blhe || blhe->type != bfd_link_hash_defined)
> + continue;
> + }
> +
> sym_vma = (relocs[i]->addend
> + sym->value
> + sym->section->vma
>
>
> In message "Re: [Mingw-users] unresolved return address in
> dwarf2 FDE",
> Takashi Ono wrote...
> >Hi,
> >
> >This is a testcase.
> >
> >When we do
> >/mingw-dw2/bin/g++ -shared -shared-libgcc
> -Wl,-Map=testdll0.map -Wl,--image-base=
> >0x61000000 -o testdll0.dll testdll0.cpp -lstdc++_s
> >/mingw-dw2/bin/g++ -shared -shared-libgcc
> -Wl,-Map=testdll.map -Wl,--image-base=
> >0x61010000 -o testdll1.dll testdll10.cpp testdll11.cpp -lstdc++_s
> >/mingw-dw2/bin/g++ -mconsole -shared-libgcc -lstdc++_s
> -Wl,-Map=testmain.map -o
> >testmain.exe testmain.cpp -L. -ltestdll0 -ltestdll1
> >./testmain.exe
> >
> >The outputs are:
> >exception thorwn in func2
> >exception thorwn in func11
> >
> >But when we rebase testdll1 like this:
> >/cygdrive/c/Program\ Files/Microsoft\ Platform\
> SDK/Bin/ReBase.Exe -b 0x61020000
> >testdll1.dll
> >./testmain.exe
> >
> >The outputs are:
> >This application has requested the Runtime to terminate it
> in an unusual way.
> >Please contact the application's support team for more information.
> >exception thorwn in func2
> >terminate called after throwing an instance of 'testexception'
> >
> >--<test.h>---
> >#include <stdio.h>
> >
> >class testexception
> >{
> >};
> >
> >inline
> >void func11()
> >{
> > try
> > {
> > throw testexception();
> > }
> > catch( testexception& )
> > {
> > printf("exception thorwn in func11\n");
> > }
> >}
> >
> >void func12();
> >void func13();
> >void func2();
> >-------
> >
> >--<testdll0.cpp>---
> >#include "test.h"
> >
> >void func2()
> >{
> > try
> > {
> > throw testexception();
> > }
> > catch( testexception& )
> > {
> > printf("exception thorwn in func2\n");
> > }
> >}
> >-------
> >
> >--<testdll10.cpp>---
> >#include "test.h"
> >
> >void func12()
> >{
> > func11();
> >}
> >-------
> >
> >--<testdll11.cpp>---
> >#include "test.h"
> >
> >void func13()
> >{
> > func11();
> >}
> >-------
> >
> >--<testmain.cpp>---
> >#include "test.h"
> >
> >int main()
> >{
> > func2();
> > func12();
> >}
> >-------
> >
> >
> >
> >In message "RE: unresolved return address in dwarf2 FDE",
> >Danny Smith wrote...
> > >
> > >>
> > >> However, the pe-ld still emits a relocation entry for the
> > >> never resolved reference to
> > >> the symbol in the discarded section in eh_frame. So it will
> > >> cause a problem if the
> > >> executable .exe or .dll is relocated or rebased as the
> > >> reference becomes nonzero.
> > >>
> > >Could you provide a small testcase, please?
> > >Danny
> > >
> >
> >----
> > Takashi Ono(HK Freak)
> > mailto:t_ono@xxxxxxxxxxx or MHF00056@xxxxxxxxxxx
> > (Personal Address, checked every morning/evening and holidays)
> > mailto:t_ono@xxxxxxxxxxxxxxxx
> > (Address for business, checked every working days)
> > http://www.hkfreak.net
> >
>
> >-------------------------------------------------------------
> ------------
> >This SF.net email is sponsored by: Microsoft
> >Defy all challenges. Microsoft(R) Visual Studio 2005.
> >http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> >_______________________________________________
> >MinGW-users mailing list
> >MinGW-users@xxxxxxxxxxxxxxxxxxxxx
> >
> >You may change your MinGW Account Options or unsubscribe at:
> >https://lists.sourceforge.net/lists/listinfo/mingw-users
>
> ----
> Takashi Ono(HK Freak)
> mailto:t_ono@xxxxxxxxxxx or MHF00056@xxxxxxxxxxx
> (Personal Address, checked every morning/evening and holidays)
> mailto:t_ono@xxxxxxxxxxxxxxxx
> (Address for business, checked every working days)
> http://www.hkfreak.net
>
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> MinGW-users mailing list
> MinGW-users@xxxxxxxxxxxxxxxxxxxxx
>
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
>
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users