Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2020-10

Support for FreeBSD PowerPC

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Curtis Hamilton

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.

Reply by email

Jonas Maebe
to Curtis Hamilton
Curtis Hamilton wrote 5 lines
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

Reply by email

Marco van de Voort
to Jonas Maebe

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

Show quoted text 9 lines
> 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.

Reply by email

Curtis Hamilton

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?

# 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 <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 "powerpc64-portbld-freebsd12.0". Type "show configuration" for configuration details. For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>.

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 0x000000001001fed8 in $fpc_initializeunits () at ../inc/system.inc:969 #2 0x0000000010000720 in $main () at pp.pas:256
(gdb) disass
No function contains program counter for selected frame. (gdb) frame 1
#1 0x000000001001fed8 in $fpc_initializeunits () at ../inc/system.inc:969 969 Procs[i].InitProc();
(gdb) disass
Dump of assembler code for function $fpc_initializeunits: 0x000000001001fe60 <+0>: mflr r0
0x000000001001fe64 <+4>: std r31,-8(r1)
0x000000001001fe68 <+8>: std r30,-16(r1)
0x000000001001fe6c <+12>: std r29,-24(r1)
0x000000001001fe70 <+16>: std r28,-32(r1)
0x000000001001fe74 <+20>: std r0,16(r1)
0x000000001001fe78 <+24>: stdu r1,-128(r1)
0x000000001001fe7c <+28>: bl 0x10002768 <fpc_cpuinit> 0x000000001001fe80 <+32>: nop
0x000000001001fe84 <+36>: addi r3,r2,15080
0x000000001001fe88 <+40>: ld r28,0(r3)
0x000000001001fe8c <+44>: cmpldi r28,1
0x000000001001fe90 <+48>: blt 0x1001feec <$fpc_initializeunits+140> 0x000000001001fe94 <+52>: li r31,0
0x000000001001fe98 <+56>: addi r3,r31,1
0x000000001001fe9c <+60>: mr r31,r3
0x000000001001fea0 <+64>: rldicr r4,r31,4,59
0x000000001001fea4 <+68>: addi r3,r2,15080
0x000000001001fea8 <+72>: ldx r3,r4,r3
0x000000001001feac <+76>: cmpldi r3,0
0x000000001001feb0 <+80>: beq 0x1001fedc <$fpc_initializeunits+124> 0x000000001001feb4 <+84>: rldicr r4,r31,4,59
0x000000001001feb8 <+88>: addi r3,r2,15080
0x000000001001febc <+92>: ldx r29,r4,r3
0x000000001001fec0 <+96>: ld r30,0(r29)
0x000000001001fec4 <+100>: std r2,40(r1)
0x000000001001fec8 <+104>: mtctr r30
0x000000001001fecc <+108>: ld r2,8(r29)
0x000000001001fed0 <+112>: ld r11,16(r29)
0x000000001001fed4 <+116>: bctrl
=> 0x000000001001fed8 <+120>: ld r2,40(r1)
0x000000001001fedc <+124>: addi r3,r2,15080
0x000000001001fee0 <+128>: std r31,8(r3)
0x000000001001fee4 <+132>: cmpld r31,r28
0x000000001001fee8 <+136>: blt 0x1001fe98 <$fpc_initializeunits+56> 0x000000001001feec <+140>: addi r3,r2,18272
0x000000001001fef0 <+144>: ld r3,0(r3)
0x000000001001fef4 <+148>: cmpldi r3,0
0x000000001001fef8 <+152>: beq 0x1001ff20 <$fpc_initializeunits+192> 0x000000001001fefc <+156>: addi r3,r2,18272
0x000000001001ff00 <+160>: ld r31,0(r3)
0x000000001001ff04 <+164>: ld r30,0(r31)
0x000000001001ff08 <+168>: std r2,40(r1)
0x000000001001ff0c <+172>: mtctr r30
0x000000001001ff10 <+176>: ld r2,8(r31)
0x000000001001ff14 <+180>: ld r11,16(r31)
0x000000001001ff18 <+184>: bctrl
0x000000001001ff1c <+188>: ld r2,40(r1)
0x000000001001ff20 <+192>: addi r1,r1,128
0x000000001001ff24 <+196>: ld r31,-8(r1)
0x000000001001ff28 <+200>: ld r30,-16(r1)
0x000000001001ff2c <+204>: ld r29,-24(r1)
0x000000001001ff30 <+208>: ld r28,-32(r1)
0x000000001001ff34 <+212>: ld r0,16(r1)
0x000000001001ff38 <+216>: mtlr r0
0x000000001001ff3c <+220>: blr
End of assembler dump.

------------------------------------------------------------------------

Reply by email

Jonas Maebe
to Curtis Hamilton
Curtis Hamilton 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

Reply by email

Curtis Hamilton
to Jonas Maebe

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 <

Show quoted text 17 lines
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 - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Curtis Hamilton
to Curtis Hamilton

Attached it the crt1.s created using gcc -S that was used in the prt0.as in my earlier email.

-regards

Curtis Hamilton wrote 28 lines
Attached is the prt0.as <http://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 <http://prt0.as> file that you created look like? Jonas _______________________________________________ fpc-devel maillist  - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email