[fpc-devel] Support for FreeBSD PowerPC

2020-11-02 Thread Curtis Hamilton via fpc-devel
Free Pascal (FPC) currently does not support FreeBSD running on PowerPC.

I need some help in getting FPC on FreeBSD/powerpc64. I’ve done preliminary
work to get the cross compiler working.  However, I’m not well versed in
assembly programming and need help in creating the proper startup code
(prt0.
[image: File]
prt0.as

Any interest and assistance is appreciated.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Support for FreeBSD PowerPC

2020-10-22 Thread Curtis Hamilton via fpc-devel
Attached it the crt1.s created using gcc -S that was used in the prt0.as 
in my earlier email.


-regards

On 10/21/20 10:51 AM, Curtis Hamilton wrote:
Attached is the prt0.as  I created using the one used 
for linux/powerpc64.  I've also attached the dump of crt1.s from the 
target.


Thanks!

On Wed, Oct 21, 2020 at 10:04 AM Jonas Maebe via fpc-devel 
> wrote:


On 20/10/2020 02:32, Curtis Hamilton via fpc-devel wrote:
> I think I maybe in over my head on this. I've taken a look and
now I'm not sure what the issue is.  The
> segfault occurs in the FPC RTL initiazation code (see backtrace
below).
>
> Any ideas?

What does the prt0.as  file that you created look
like?


Jonas
___
fpc-devel maillist  - fpc-devel@lists.freepascal.org

https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

.file   "crt1.c"
.section".got","aw"
.section".text"
#APP
.ident  "$FreeBSD: releng/12.1/lib/csu/powerpc64/crt1.c 326219 
2017-11-26 02:00:33Z pfg $"
.ident  "$FreeBSD: releng/12.1/lib/csu/common/crtbrand.c 354233 
2019-11-01 00:00:17Z gjb $"
.ident  "$FreeBSD: releng/12.1/lib/csu/common/ignore_init.c 339351 
2018-10-13 23:52:55Z kib $"
#NO_APP
.section".got","aw"
.LC2:
.tc environ[TC],environ
.LC3:
.tc .LANCHOR0[TC],.LANCHOR0
.LC4:
.tc __ps_strings[TC],__ps_strings
.LC5:
.tc _DYNAMIC[TC],_DYNAMIC
.LC6:
.tc atexit[TC],atexit
.LC7:
.tc _init_tls[TC],_init_tls
.LC8:
.tc finalizer[TC],finalizer
.LC9:
.tc __preinit_array_end[TC],__preinit_array_end
.LC10:
.tc __preinit_array_start[TC],__preinit_array_start
.LC11:
.tc _init[TC],_init
.LC12:
.tc __init_array_end[TC],__init_array_end
.LC13:
.tc __init_array_start[TC],__init_array_start
.LC14:
.tc main[TC],main
.LC15:
.tc exit[TC],exit
.section".text"
.align 2
.globl _start
.section".opd","aw"
.align 3
_start:
.quad   .L._start,.TOC.@tocbase,0
.previous
.type   _start, @function
.L._start:
mflr 0
std 28,-32(1)
mr 28,5
std 30,-16(1)
mr 30,4
std 31,-8(1)
mr 31,3
std 0,16(1)
mr 3,7
std 26,-48(1)
std 27,-40(1)
std 29,-24(1)
ld 9,.LC2@toc(2)
stdu 1,-160(1)
ld 0,0(9)
cmpdi 7,0,0
beq- 7,.L31
.L2:
cmpwi 7,31,0
ble- 7,.L4
ld 9,0(30)
cmpdi 7,9,0
beq- 7,.L4
ld 11,.LC3@toc(2)
std 9,0(11)
lbz 0,0(9)
cmpdi 7,0,0
beq- 7,.L4
addi 9,9,1
b .L8
.L11:
lbz 0,0(9)
addi 9,9,1
cmpdi 7,0,0
beq- 7,.L4
.L8:
cmpwi 7,0,47
bne+ 7,.L11
std 9,0(11)
lbz 0,0(9)
addi 9,9,1
cmpdi 7,0,0
bne+ 7,.L8
.L4:
cmpdi 7,8,0
beq- 7,.L12
ld 9,.LC4@toc(2)
std 8,0(9)
.L12:
ld 0,.LC5@toc(2)
cmpdi 7,0,0
beq- 7,.L14
ld 9,.LC6@toc(2)
std 2,40(1)
ld 0,0(9)
ld 11,16(9)
mtctr 0
ld 2,8(9)
bctrl
ld 2,40(1)
.L16:
ld 9,.LC14@toc(2)
mr 3,31
std 2,40(1)
mr 4,30
mr 5,28
ld 0,0(9)
ld 11,16(9)
mtctr 0
ld 2,8(9)
bctrl
ld 2,40(1)
ld 9,.LC15@toc(2)
ld 0,0(9)
ld 11,16(9)
mtctr 0
ld 2,8(9)
bctrl
ld 2,40(1)
.L31:
std 5,0(9)
b .L2
.L14:
ld 9,.LC7@toc(2)
std 2,40(1)
ld 0,0(9)
ld 11,16(9)
mtctr 0
ld 2,8(9)
bctrl
ld 2,40(1)
ld 9,.LC6@toc(2)
ld 3,.LC8@toc(2)
ld 0,0(9)
ld 11,16(9)
mtctr 0
ld 2,8(9)
bctrl
ld 2,40(1)
ld 0,.LC9@toc(2)
ld 26,.LC10@toc(2)
subf 0,26,0
sradi. 27,0,3
beq- 0,.L17
li 29,0
b .L19
.L20:
addi 29,29,1
cmpd 7,27,29
beq- 7,.L17
.L19:
sldi 0,29,3
ldx 9,26,0
cmpldi 7,9,1
ble+ 7,.L20
ld 0,0(9)
mr 3,31
std 2,40(1)
mr 4,30
mtctr 0
mr 5,28
ld 11,16(9)
ld 2,8(9)
bctrl
ld 2,40(1)
b .L20
.L17:
ld 9,.LC11@toc(2)
std 2,40(1)
ld 0,0(9)
ld 11,16(9)
mtctr 0
ld 2,8(9)
bctrl
ld 2,40(1)
ld 0,.LC12@toc(2)
ld 26,.LC13@toc(2)
subf 0,26,0
sradi. 27,0,3
beq- 0,.L16
li 29,0
b .L23
.L24:
addi 29,29,1
cmpd 7,27,29
beq- 7,.L16
.L23:

Re: [fpc-devel] Support for FreeBSD PowerPC

2020-10-21 Thread Curtis Hamilton via fpc-devel
Attached is the prt0.as I created using the one used for linux/powerpc64.
I've also attached the dump of crt1.s from the target.

Thanks!

On Wed, Oct 21, 2020 at 10:04 AM Jonas Maebe via fpc-devel <
fpc-devel@lists.freepascal.org> wrote:

> On 20/10/2020 02:32, Curtis Hamilton via fpc-devel wrote:
> > I think I maybe in over my head on this. I've taken a look and now I'm
> not sure what the issue is.  The
> > segfault occurs in the FPC RTL initiazation code (see backtrace below).
> >
> > Any ideas?
>
> What does the prt0.as file that you created look like?
>
>
> Jonas
> ___
> fpc-devel maillist  -  fpc-devel@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>


prt0.as
Description: application/applix-spreadsheet


crt1.dump
Description: Binary data
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Support for FreeBSD PowerPC

2020-10-21 Thread Jonas Maebe via fpc-devel
On 20/10/2020 02:32, Curtis Hamilton via fpc-devel wrote:
> I think I maybe in over my head on this. I've taken a look and now I'm not 
> sure what the issue is.  The 
> segfault occurs in the FPC RTL initiazation code (see backtrace below). 
> 
> Any ideas?

What does the prt0.as file that you created look like?


Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Support for FreeBSD PowerPC

2020-10-19 Thread Curtis Hamilton via fpc-devel

Op 2020-10-18 om 23:03 schreef Jonas Maebe via fpc-devel:
//>>>/I’ve been able to create a cross compiler using the guidance and some />>>/additional information.  But I’ve been unable to create the proper FPC />>>/startup code (prt0.as) needed. />>>//>>>/Any help would be appreciated. />>/I believe these files are generally created by disassembling the />>/system's crt1.o (objdump -d) and then changing the call(s) to the libc />>/intialisation code with calls to the FPC RTL intialisation code. />Afaik mostly gcc -S.  Trunk SVN also contains an untested and incomplete 

attempt at translating the C startup files to pascal.


Thanks!

I think I maybe in over my head on this. I've taken a look and now I'm not sure 
what the issue is.  The
segfault occurs in the FPC RTL initiazation code (see backtrace below).

Any ideas?


root@blackbird:/usr/ports/tmp/fpc-powerpc64/lib/fpc/3.2.0 # gdb ./ppcppc64 
ppcppc64.core
GNU gdb (GDB) 8.3 [GDB v8.3 for FreeBSD]
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
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 "powerpc64-portbld-freebsd12.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./ppcppc64...

warning: core file may not match specified executable file.
[New LWP 100454]
Core was generated by `./ppcppc64'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x7c0802a6fbe1fff8 in ?? ()
(gdb) backtrace
#0  0x7c0802a6fbe1fff8 in ?? ()
#1  0x1001fed8 in $fpc_initializeunits () at ../inc/system.inc:969
#2  0x1720 in $main () at pp.pas:256
(gdb) disass
No function contains program counter for selected frame.
(gdb) frame 1
#1  0x1001fed8 in $fpc_initializeunits () at ../inc/system.inc:969
969  Procs[i].InitProc();
(gdb) disass
Dump of assembler code for function $fpc_initializeunits:
   0x1001fe60 <+0>:   mflrr0
   0x1001fe64 <+4>:   std r31,-8(r1)
   0x1001fe68 <+8>:   std r30,-16(r1)
   0x1001fe6c <+12>:  std r29,-24(r1)
   0x1001fe70 <+16>:  std r28,-32(r1)
   0x1001fe74 <+20>:  std r0,16(r1)
   0x1001fe78 <+24>:  stdur1,-128(r1)
   0x1001fe7c <+28>:  bl  0x10002768 
   0x1001fe80 <+32>:  nop
   0x1001fe84 <+36>:  addir3,r2,15080
   0x1001fe88 <+40>:  ld  r28,0(r3)
   0x1001fe8c <+44>:  cmpldi  r28,1
   0x1001fe90 <+48>:  blt 0x1001feec <$fpc_initializeunits+140>
   0x1001fe94 <+52>:  li  r31,0
   0x1001fe98 <+56>:  addir3,r31,1
   0x1001fe9c <+60>:  mr  r31,r3
   0x1001fea0 <+64>:  rldicr  r4,r31,4,59
   0x1001fea4 <+68>:  addir3,r2,15080
   0x1001fea8 <+72>:  ldx r3,r4,r3
   0x1001feac <+76>:  cmpldi  r3,0
   0x1001feb0 <+80>:  beq 0x1001fedc <$fpc_initializeunits+124>
   0x1001feb4 <+84>:  rldicr  r4,r31,4,59
   0x1001feb8 <+88>:  addir3,r2,15080
   0x1001febc <+92>:  ldx r29,r4,r3
   0x1001fec0 <+96>:  ld  r30,0(r29)
   0x1001fec4 <+100>: std r2,40(r1)
   0x1001fec8 <+104>: mtctr   r30
   0x1001fecc <+108>: ld  r2,8(r29)
   0x1001fed0 <+112>: ld  r11,16(r29)
   0x1001fed4 <+116>: bctrl
=> 0x1001fed8 <+120>:  ld  r2,40(r1)
   0x1001fedc <+124>: addir3,r2,15080
   0x1001fee0 <+128>: std r31,8(r3)
   0x1001fee4 <+132>: cmpld   r31,r28
   0x1001fee8 <+136>: blt 0x1001fe98 <$fpc_initializeunits+56>
   0x1001feec <+140>: addir3,r2,18272
   0x1001fef0 <+144>: ld  r3,0(r3)
   0x1001fef4 <+148>: cmpldi  r3,0
   0x1001fef8 <+152>: beq 0x1001ff20 <$fpc_initializeunits+192>
   0x1001fefc <+156>: addir3,r2,18272
   0x1001ff00 <+160>: ld  r31,0(r3)
   0x1001ff04 <+164>: ld  r30,0(r31)
   0x1001ff08 <+168>: std r2,40(r1)
   0x1001ff0c <+172>: mtctr   r30
   0x1001ff10 <+176>: ld  r2,8(r31)
   0x1001ff14 <+180>: ld  r11,16(r31)
   0x1001ff18 <+184>: bctrl
   0x1001ff1c <+188>: ld  r2,40(r1)
   0x1001ff20 <+192>: addir1,r1,128
   0x1001ff24 <+196>: ld

Re: [fpc-devel] Support for FreeBSD PowerPC

2020-10-18 Thread Marco van de Voort via fpc-devel


Op 2020-10-18 om 23:03 schreef Jonas Maebe via fpc-devel:



I’ve been able to create a cross compiler using the guidance and some
additional information.  But I’ve been unable to create the proper FPC
startup code (prt0.as) needed.

Any help would be appreciated.

I believe these files are generally created by disassembling the
system's crt1.o (objdump -d) and then changing the call(s) to the libc
intialisation code with calls to the FPC RTL intialisation code.
Afaik mostly gcc -S.  Trunk SVN also contains an untested and incomplete 
attempt at translating the C startup files to pascal.

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Support for FreeBSD PowerPC

2020-10-18 Thread Jonas Maebe via fpc-devel
On 14/10/2020 17:45, Curtis Hamilton via fpc-devel wrote:

> I’ve been able to create a cross compiler using the guidance and some
> additional information.  But I’ve been unable to create the proper FPC
> startup code (prt0.as) needed.
> 
> Any help would be appreciated.

I believe these files are generally created by disassembling the
system's crt1.o (objdump -d) and then changing the call(s) to the libc
intialisation code with calls to the FPC RTL intialisation code.


Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] Support for FreeBSD PowerPC

2020-10-15 Thread Curtis Hamilton via fpc-devel
Hello,

I’d like to know if there is any interest in providing FPC for
FreeBSD/PowerPC, specifically 64-bit.

In case there is no interest, I’m looking for some assistance.

First, I’m not an experienced programmer, but I’ve attempted to port FPC,
using the guidance at
https://wiki.freepascal.org/Porting_the_Unix_rtl_to_a_new_target.

I’ve been able to create a cross compiler using the guidance and some
additional information.  But I’ve been unable to create the proper FPC
startup code (prt0.as) needed.

Any help would be appreciated.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel