m68k-atari-mint-gcc and generation of PC relative code

GFA, ASM, STOS, ...

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

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

m68k-atari-mint-gcc and generation of PC relative code

Postby simonsunnyboy » Tue Oct 02, 2018 5:27 pm

Is this possible?
I get "Not supported" for -fPIC and -fpic options
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

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

czietz
Hardware Guru
Hardware Guru
Posts: 763
Joined: Tue May 24, 2016 6:47 pm

Re: m68k-atari-mint-gcc and generation of PC relative code

Postby czietz » Tue Oct 02, 2018 5:42 pm

Have a look at -mpcrel.

ThorstenOtto
Captain Atari
Captain Atari
Posts: 400
Joined: Sun Aug 03, 2014 5:54 pm

Re: m68k-atari-mint-gcc and generation of PC relative code

Postby ThorstenOtto » Tue Oct 02, 2018 9:28 pm

IIRC -fPIC works when you compile for 68020 at least. -mpcrel sometimes can throw an internal compiler error when accessing struct members.

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

Re: m68k-atari-mint-gcc and generation of PC relative code

Postby simonsunnyboy » Wed Oct 03, 2018 8:12 am

-mpcrel works fine for my example. No internal compiler error at this point.
Gneerating code only for 020 and up would be a limitation. For me always plain 000 code is the goal.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

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

BlankVector
Captain Atari
Captain Atari
Posts: 457
Joined: Wed Oct 24, 2007 7:52 pm
Location: France
Contact:

Re: m68k-atari-mint-gcc and generation of PC relative code

Postby BlankVector » Wed Oct 03, 2018 11:50 am

-fPIC and -fpic options require a Global Offset Table (GOT), and I considered it was not possible with our limited a.out file format. This why you see "Not supported" errors. When available, -fpic is limited to 16-bit offsets, while -fPIC allows full 32-bit offsets

-mpcrel: As I understand, this is an additional flag to -fPIC/-fpic to avoid using the GOT. So it should work fine on our target (as other people mentioned). -mpcrel alone implies -fpic, which means limitation to 16-bit offsets. The doc of GCC 4.6.4 says that -mpcrel combined to -fPIC could be possible on 68020+, but not yet supported.

What I understand is that -mpcrel is only useful for small programs (< 32 KB), and there is no general solution for full 32-bit PC-relative programs without GOT.
Subscribe to my Vretrocomputing channel on YouTube and Facebook.

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

Re: m68k-atari-mint-gcc and generation of PC relative code

Postby simonsunnyboy » Wed Oct 03, 2018 1:43 pm

I was actually toying with the idea to write bootsector code as a single void f(void) function in C and then extracting the code with objcopy

Just to check if it can be done.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

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

ThorstenOtto
Captain Atari
Captain Atari
Posts: 400
Joined: Sun Aug 03, 2014 5:54 pm

Re: m68k-atari-mint-gcc and generation of PC relative code

Postby ThorstenOtto » Wed Oct 03, 2018 3:31 pm

simonsunnyboy wrote:I was actually toying with the idea to write bootsector code as a single void f(void) function in C and then extracting the code with objcopy

Just to check if it can be done.


Can't you use Pure-C for that?

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

Re: m68k-atari-mint-gcc and generation of PC relative code

Postby simonsunnyboy » Wed Oct 03, 2018 5:43 pm

Maybe I could but I want to use crosscompilers these days.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

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

BlankVector
Captain Atari
Captain Atari
Posts: 457
Joined: Wed Oct 24, 2007 7:52 pm
Location: France
Contact:

Re: m68k-atari-mint-gcc and generation of PC relative code

Postby BlankVector » Wed Oct 03, 2018 5:57 pm

simonsunnyboy wrote:I was actually toying with the idea to write bootsector code as a single void f(void) function in C and then extracting the code with objcopy

I thing this should work :)
Subscribe to my Vretrocomputing channel on YouTube and Facebook.


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests