XTC68 C Cross compiler

Anything QL Software or Programming Related.
User avatar
NormanDunbar
Super Gold Card
Posts: 544
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

XTC68 C Cross compiler

Postby NormanDunbar » Tue Oct 30, 2018 11:46 am

I came across this when I was looking at something else, and fell down the rabbit hole!

The following applies to compiling etc on a Linux 64bit but with the correct packages installed to allow 32 bit code to be compiled and executed.

I've forked the compiler sources from the SinclairQL original at https://github.com/SinclairQL/xtc68 and compiled it. Even with a simple text file:

Code: Select all

#include <INCLUDE_stdio.h>

int main(int argc, char *argv[]) {
   printf("\n\nHello World!\n\n");
   return 0;
}


I get a complete failure to run the as68 phase due to a perceived 'stack overflow exploit' attempt:

Code: Select all

qcc -o test test.c -I ../support
*** stack smashing detected ***: as68 terminated
Aborted


I suspect that there might be a bug in the as68 code that's giving this impression. There are certainly a lot of warnings when compiling most of the code in all the utilities. I might have to work through them to see if I can get rid and then I might be able to see the wood for the trees. The generated code from the above C source is:

Code: Select all

! Generated by c68 4.5 27 Feb 99 (Oct 30 2018) from "test.i"
   .sect   .text
   .sect   .rom
   .sect   .data
   .sect   .bss
   .sect   .text
I_1:
   .data1   0xa,0xa
   .ascii   "Hello World!"
   .data1   0xa,0xa,0x0
   .align   2
   .extern _main
_main:
   bra   I_2
I_3:
   pea   I_1
   jsr   _printf
   move.l   #0,d0
I_4:
   unlk   a6
   rts
I_2:
   link   a6,#0
   bra   I_3


This doesn't look too bad to me, hence my suspicion that it's internal to as68 itself. If I comment out the two lines at label I_3, so that it effectively does nothing, it will assemble.

Q1. Has anyone attempted to use this compiler? Successfully? It could be I've compiled with the wrong options - instructions are few and far between. Google, in this case, is of little help either.

Q2. I'm not seeing any libraries in this installation, so I suspect the linker (qld) will not work either, leading to a complete lack of executable files?

Thanks.


Cheers,
Norm.


Why do they put lightning conductors on churches?
How come Tarzan never grew a beard?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's a man in Germany who fits indicators on BMWs.
User avatar
NormanDunbar
Super Gold Card
Posts: 544
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: XTC68 C Cross compiler

Postby NormanDunbar » Tue Oct 30, 2018 12:14 pm

Ok, resolved Q2 (Above) by grabbing the various libraries from Dilwyn's fine web site of all things good - http://www.dilwyn.me.uk/c/XTC68LIB.ZIP

I can now get the linker to output a QDOS executable. I just need to fix as68 now....


Cheers,
Norm.


Why do they put lightning conductors on churches?
How come Tarzan never grew a beard?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's a man in Germany who fits indicators on BMWs.
User avatar
tofro
QL Wafer Drive
Posts: 1436
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: XTC68 C Cross compiler

Postby tofro » Tue Oct 30, 2018 1:05 pm

Norman,

you could get rid of the error and abort by compiling as68 with

Code: Select all

-fno-stack-protector


The error is normally caused by a buffer overflow on the stack (string too long?). The likelihood you'll get another crash for the same reason is high, though (if the code does not smash the stack canaries, it will probably smash something more important....)

I did use xtc68 quite some years ago, but on DOS/OS2 only, and only used precompiled versions. With the fast QDOSSMSQ platforms we have to day, I feel XTC68 is a bit obsolete.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Peter
Super Gold Card
Posts: 680
Joined: Sat Jan 22, 2011 8:47 am

Re: XTC68 C Cross compiler

Postby Peter » Tue Oct 30, 2018 1:10 pm

NormanDunbar wrote:Q1. Has anyone attempted to use this compiler? Successfully?

I'm still using it successfully under WIndoze. But like Tobias, I did not recompile.
It could make sense to post the issue at the ql-developers mailing list.

Peter


User avatar
NormanDunbar
Super Gold Card
Posts: 544
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: XTC68 C Cross compiler

Postby NormanDunbar » Tue Oct 30, 2018 2:29 pm

Thanks Tobias,

that fix worked - for now anyway. The code compiles happily and executes on QPC with no problems, once I've got the XTcc record extracted and the dataspace sorted out.

Cheers,
Norm.


Why do they put lightning conductors on churches?
How come Tarzan never grew a beard?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's a man in Germany who fits indicators on BMWs.
User avatar
NormanDunbar
Super Gold Card
Posts: 544
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: XTC68 C Cross compiler

Postby NormanDunbar » Tue Oct 30, 2018 2:30 pm

Peter wrote:I'm still using it successfully under WIndoze. But like Tobias, I did not recompile.
It could make sense to post the issue at the ql-developers mailing list.
Peter


Thanks Peter. Tobias' fix seems to have done the trick. I'm sure that it might bite me somewhere down the line. We shall see.


Cheers,
Norm.


Why do they put lightning conductors on churches?
How come Tarzan never grew a beard?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's a man in Germany who fits indicators on BMWs.
User avatar
XorA
Super Gold Card
Posts: 561
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: XTC68 C Cross compiler

Postby XorA » Tue Oct 30, 2018 2:42 pm

I fixed that bug years ago.

https://github.com/xXorAa/xtc68/tree/fix-stack-smashing

Its an actual bug in the code.


User avatar
NormanDunbar
Super Gold Card
Posts: 544
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: XTC68 C Cross compiler

Postby NormanDunbar » Tue Oct 30, 2018 3:05 pm

Thanks muchly.
Fix applied - all working now.

Cheers,
Norm.


Why do they put lightning conductors on churches?
How come Tarzan never grew a beard?
If at first you don't succeed, don't take up skydiving!
If you think your job is pointless, remember, there's a man in Germany who fits indicators on BMWs.
User avatar
Peter
Super Gold Card
Posts: 680
Joined: Sat Jan 22, 2011 8:47 am

Re: XTC68 C Cross compiler

Postby Peter » Wed Oct 31, 2018 9:24 am

XorA wrote:I fixed that bug years ago.

https://github.com/xXorAa/xtc68/tree/fix-stack-smashing

Could this be linked to a website where one would usually look when searching for XTC68?
e.g. http://www.dilwyn.me.uk/c/index.html ? Dilwyn?


User avatar
XorA
Super Gold Card
Posts: 561
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: XTC68 C Cross compiler

Postby XorA » Wed Oct 31, 2018 10:10 am

Peter wrote:
XorA wrote:I fixed that bug years ago.

https://github.com/xXorAa/xtc68/tree/fix-stack-smashing

Could this be linked to a website where one would usually look when searching for XTC68?
e.g. http://www.dilwyn.me.uk/c/index.html ? Dilwyn?


Who is in charge of SinclairQL/xtc68? We could just push the fix there! I did send a pull request to the original author but that has not been processed!



Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 3 guests