GCC without MintLib - missing helper functions?

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4872
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

GCC without MintLib - missing helper functions?

Postby simonsunnyboy » Wed Mar 02, 2016 4:19 pm

If I don't link MintLib and use a very basic startup code (mfro design), gcc cannot compile int32_t (long) /10 or %10...some helper functions are missing:

Linking C executable file.tos
/usr/bin/cmake -E cmake_link_script CMakeFiles/file.tos.dir/link.txt --verbose=1
CMakeFiles/file.tos.dir/test/test_filefunc.c.o:CMakeFiles/file.tos.dir/test/test_filefunc.c.o:(.text+0x12): undefined reference to `___modsi3'
CMakeFiles/file.tos.dir/test/test_filefunc.c.o:CMakeFiles/file.tos.dir/test/test_filefunc.c.o:(.text+0x18): undefined reference to `___divsi3'
CMakeFiles/file.tos.dir/test/test_filefunc.c.o:CMakeFiles/file.tos.dir/test/test_filefunc.c.o:(.text+0x4a): undefined reference to `___modsi3'
CMakeFiles/file.tos.dir/test/test_filefunc.c.o:CMakeFiles/file.tos.dir/test/test_filefunc.c.o:(.text+0x50): undefined reference to `___divsi3'
collect2: ld returned 1 exit status
make[3]: *** [file.tos] Fehler 1
make[2]: *** [CMakeFiles/file.tos.dir/all] Fehler 2
make[1]: *** [CMakeFiles/file.tos.dir/rule] Fehler 2

Is the source for these helpers available so I can compile and link them?

PS: Crossposted in the cross gcc group on FB....
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 689
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: GCC without MintLib - missing helper functions?

Postby mfro » Wed Mar 02, 2016 6:14 pm

you need to link to the gcc runtime library (libgcc.a) that provides basic arithmetic functions not directly supported by the processor (like 32 bit signed division or modulo operation as in your case).

Just add

Code: Select all

-lgcc

to your compiler command line.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4872
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: GCC without MintLib - missing helper functions?

Postby simonsunnyboy » Thu Mar 03, 2016 4:52 pm

Yep, that seems to be the missing link. Why does gcc need an explicit link instruction for this? Shouldn't it link those basic needed snippets by itself?
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4872
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: GCC without MintLib - missing helper functions?

Postby simonsunnyboy » Thu Mar 03, 2016 5:24 pm

Another question, Hatari reports me "illegal instruction" and bombs. Yet if I diassemble my code I cannot find the illegal instruction $4E30.
Is Hatari at fault here or my gcc file?
You do not have the required permissions to view the files attached to this post.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 689
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: GCC without MintLib - missing helper functions?

Postby mfro » Thu Mar 03, 2016 6:05 pm

simonsunnyboy wrote:Yep, that seems to be the missing link. Why does gcc need an explicit link instruction for this? Shouldn't it link those basic needed snippets by itself?


It does. Normally.

But since you probably link with either -nostdlib or -standalone to avoid mintlib overhead, it doesn't and you need to help it.

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 689
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: GCC without MintLib - missing helper functions?

Postby mfro » Thu Mar 03, 2016 6:07 pm

simonsunnyboy wrote:Another question, Hatari reports me "illegal instruction" and bombs. Yet if I diassemble my code I cannot find the illegal instruction $4E30.
Is Hatari at fault here or my gcc file?


It would be probably easier to help you if you posted your sources as well.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4872
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: GCC without MintLib - missing helper functions?

Postby simonsunnyboy » Thu Mar 03, 2016 6:37 pm

Never mind, I located it by now, typical pointer nirvana mess :|
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4872
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: GCC without MintLib - missing helper functions?

Postby simonsunnyboy » Thu Mar 03, 2016 6:39 pm

mfro wrote:
simonsunnyboy wrote:Yep, that seems to be the missing link. Why does gcc need an explicit link instruction for this? Shouldn't it link those basic needed snippets by itself?


It does. Normally.

But since you probably link with either -nostdlib or -standalone to avoid mintlib overhead, it doesn't and you need to help it.


Well those helpers are not part of any standard lib but of the compiler implementation itself. I did assume such stuff would NOT be part of the excluded stdlib ;)

But anyway, it is working correctly now.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 3 guests