ld is crashing on undefined symbols?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ld is crashing on undefined symbols?

Pedro Alves-4
Something I almost forgot.  I noticed something's wrong with ld, when I build
the WM6.1 testcase:

#include <windows.h>

BOOL WINAPI
DllMainCRTStartup (HANDLE h, DWORD reason, LPVOID lpReserved)
{
  return TRUE;
}

static char big_buf[0x010000] = { '1' };

extern DWORD __U(__RUNTIME_PSEUDO_RELOC_LIST__);
extern DWORD __U(_image_base__);

extern DWORD __U(_my_image_base__);

__declspec (dllexport)
int doit (void)
{
        void *p;
        p = &__U(_my_image_base__);
        // p = &__size_of_heap_commit__;
        // p = &__U(_image_base__);
// p = &__U(__RUNTIME_PSEUDO_RELOC_LIST__);
// p = DllMainCRTStartup;

        return (int)p;
}

and forgot to define the __my_image_base__ symbol.  I got this ld crash:

>gdb-head --args arm-mingw32ce-ld --shared -Bdynamic -e DllMainCRTStartup -o lib7.dll lib7.o -lcoredll
GNU gdb (GDB) 7.0.50.20091231-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /opt/mingw32ce-trunk/bin/arm-mingw32ce-ld...done.
(gdb) r
Starting program: /opt/mingw32ce-trunk/bin/arm-mingw32ce-ld --shared -Bdynamic -e DllMainCRTStartup -o lib7.dll lib7.o -lcoredll
lib7.o:lib7.c:(.text
Program received signal SIGSEGV, Segmentation fault.
0x0000000000417e4b in vfinfo (fp=0x7ffff7bc3860, fmt=0x474559 "+0x%v)", arg=0x7fffffffd800, is_warning=0)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/ld/ldmisc.c:177
177                     if (abfd != NULL
(gdb) bt
#0  0x0000000000417e4b in vfinfo (fp=0x7ffff7bc3860, fmt=0x474559 "+0x%v)", arg=0x7fffffffd800, is_warning=0)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/ld/ldmisc.c:177
#1  0x0000000000418478 in lfinfo (file=0x2, fmt=0x1 <Address 0x1 out of bounds>)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/ld/ldmisc.c:469
#2  0x0000000000417cd0 in vfinfo (fp=0x7ffff7bc3860, fmt=0x4731a4 ": undefined reference to `%T'\n",
    arg=0x7fffffffd9f0, is_warning=1) at /home/pedro/cegcc/trunk/cegcc/src/binutils/ld/ldmisc.c:349
#3  0x00000000004185ca in einfo (fmt=0x1 <Address 0x1 out of bounds>)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/ld/ldmisc.c:438
#4  0x0000000000413758 in undefined_symbol (info=<value optimized out>, name=0x6c6666 "__my_image_base__",
    abfd=0x6c41a0, section=0x6c5b00, address=84, error=1)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/ld/ldmain.c:1229
#5  0x000000000043d781 in coff_arm_relocate_section (output_bfd=0x6b7ea0, info=0x6a93e0, input_bfd=0x6c41a0,
    input_section=0x7ffff7930bc0, contents=0x71db70 "\004\260-\345", relocs=<value optimized out>, syms=0x71d730,
    sections=0x71d920) at /home/pedro/cegcc/trunk/cegcc/src/binutils/bfd/coff-arm.c:1573
#6  0x00000000004479e3 in _bfd_coff_link_input_bfd (finfo=0x7fffffffe000, input_bfd=0x6c41a0)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/bfd/cofflink.c:2350
#7  0x000000000044a769 in coff_arm_final_link_postscript (abfd=0x6b7ea0, pfinfo=0x7fffffffe000)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/bfd/coff-arm.c:2522
#8  0x0000000000448cca in _bfd_coff_final_link (abfd=0x6b7ea0, info=0x6a93e0)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/bfd/cofflink.c:926
#9  0x0000000000414f98 in ldwrite () at /home/pedro/cegcc/trunk/cegcc/src/binutils/ld/ldwrite.c:568
#10 0x0000000000414865 in main (argc=9, argv=0x7fffffffe2e8)
    at /home/pedro/cegcc/trunk/cegcc/src/binutils/ld/ldmain.c:464
(gdb)        

Could this be related to the recent experimental changes?  I would be a
good idea to run the binutils testsuites, and check for regressions (with
--target=arm-wince-pe, cause --target=arm-mingw32ce skips many important tests).

I won't have time to investigate this today.

--
Pedro Alves

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Cegcc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/cegcc-devel
Reply | Threaded
Open this post in threaded view
|

Re: ld is crashing on undefined symbols?

Danny Backx
On Thu, 2009-12-31 at 17:46 +0000, Pedro Alves wrote:
> and forgot to define the __my_image_base__ symbol.  I got this ld crash:
>
> >gdb-head --args arm-mingw32ce-ld --shared -Bdynamic -e DllMainCRTStartup -o lib7.dll lib7.o -lcoredll

I've not been able to reproduce with the attached source and this
command :
pavilion: {2346} arm-mingw32ce-ld --shared -Bdynamic -e
DllMainCRTStartup -o lib7.dll lib7.o -lcoredll
lib7.o:lib7.c:(.text+0x74): undefined reference to `_fake'

Do you still see it ?

        Danny

--
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Cegcc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

lib7.c (631 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ld is crashing on undefined symbols?

Pedro Alves-4
On Monday 04 January 2010 16:17:08, Danny Backx wrote:

> On Thu, 2009-12-31 at 17:46 +0000, Pedro Alves wrote:
> > and forgot to define the __my_image_base__ symbol.  I got this ld crash:
> >
> > >gdb-head --args arm-mingw32ce-ld --shared -Bdynamic -e DllMainCRTStartup -o lib7.dll lib7.o -lcoredll
>
> I've not been able to reproduce with the attached source and this
> command :
> pavilion: {2346} arm-mingw32ce-ld --shared -Bdynamic -e
> DllMainCRTStartup -o lib7.dll lib7.o -lcoredll
> lib7.o:lib7.c:(.text+0x74): undefined reference to `_fake'
>
> Do you still see it ?

Ah!  I don't see it anymore.  Probably fixed itself with a
clean rebuild.

--
Pedro Alves

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Cegcc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/cegcc-devel