Recent

Author Topic: fpc/arm broken  (Read 7566 times)

vincococka

  • Full Member
  • ***
  • Posts: 101
fpc/arm broken
« on: April 02, 2015, 04:19:42 pm »
Hi all

I`ve tried today the FPCUP, but applications targeted for WinCE/arm refuse to run.

See following disassemblies (I think that last 2 lines are important in both of them):
Code: [Select]
CodeTyphon 5.2 disassembly - WORKING/OK:
------------------------
.text:00015A44
.text:00015A44                 EXPORT start
.text:00015A44 start
.text:00015A44                 STMFD   SP!, {LR}
.text:00015A48                 MOV     R1, #0
.text:00015A4C                 LDR     R0, =byte_170CC
.text:00015A50                 STRB    R1, [R0]
.text:00015A54                 BL      sub_15A18
.text:00015A58     

FPC trunk (SVN rev. 30402) disassembly - application won`t start:
----------------------
.text:00016180                 EXPORT start
.text:00016180 start
.text:00016180                 STMFD   SP!, {LR}
.text:00016184                 MOV     R1, #0
.text:00016188                 LDR     R0, =byte_18150
.text:0001618C                 STRB    R1, [R0]
.text:00016190
.text:00016190 loc_16190                               
.text:00016190                 BL      loc_16190

Following code was compiled:
Code: [Select]
program project1;

{$mode objfpc}{$H+}

var
  f: TEXT;

begin
  AssignFile(f, '\test.txt');
  Rewrite(f);
  WriteLn(f, 'Hello WinCE');
  Flush(f);
  Close(f);
end.

If we compare both disassemblies, it seems like trunk FPC compiler (SVN rev. 30402) generates loop on program beginning (label loc_16190 and then instruction BL loc_16190), but release of FPC (SVN rev. 29427) is fine.
Even FPC release from CT 5231 worked OK (FPC/SVN rev.30093).

Anybody aware of the change that may cause this behaviour?

Regards,
  Vince
---
  Guide me God and I`ll find you

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fpc/arm broken
« Reply #1 on: April 02, 2015, 05:51:19 pm »
It seems that SVN commit 30181 is responsible for this behaviour.
http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=30181

PS: laksen are you here? :)
---
  Guide me God and I`ll find you

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: fpc/arm broken
« Reply #2 on: April 02, 2015, 06:56:59 pm »
I'm here, yes.

What command line did you use to build with?

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fpc/arm broken
« Reply #3 on: April 02, 2015, 08:10:51 pm »
Hi,

I`ve used following command:

Code: [Select]
r:\devel\fpc\bin\i386-win32>ppcrossarm.exe c:\Temp\fpc-wince\project1.lpr
Free Pascal Compiler version 3.1.1 [2015/04/02] for arm
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: WinCE for ARM
Compiling c:\Temp\fpc-wince\project1.lpr
Linking c:\Temp\fpc-wince\project1.exe
15 lines compiled, 0.0 sec, 24640 bytes code, 860 bytes data

But same binary output came from LAZARUS IDE configured for OS=Windows CE, and CPU family=arm, Processor was not selected
---
  Guide me God and I`ll find you

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: fpc/arm broken
« Reply #4 on: April 02, 2015, 08:27:03 pm »
Alright. Found the bug, it should be fixed now.

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fpc/arm broken
« Reply #5 on: April 02, 2015, 10:54:58 pm »
Hi Laksen,

OMG, what a quick response with fix.

I`ve tried again to compile for arm/WinCE.. it seems little bit better but we have still some issue somewhere further..
Take a look on this (especially lines with ASCII arrow on left side - follow BL asm instruction):

Code: [Select]
.text:00016170                 EXPORT start
.text:00016170 start
.text:00016170                 STMFD           SP!, {LR}
.text:00016174                 MOV             R1, #0
.text:00016178                 LDR             R0, =byte_18150
.text:0001617C                 STRB            R1, [R0]
--> .text:00016180             BL              sub_16144
.text:00016184                 LDMFD           SP!, {PC}

.text:00016144                 STMFD           SP!, {R11,R12,LR,PC}
.text:00016148                 SUB             R11, R12, #4
.text:0001614C                 SUB             SP, SP, #0x2C
.text:00016150                 MOV             R1, #0
.text:00016154                 LDR             R0, =byte_18140
.text:00016158                 STRB            R1, [R0]
.text:0001615C                 MOV             R11, #0
--> .text:00016160             BL              loc_11334


.text:00011334 ; START OF FUNCTION CHUNK FOR sub_16144
.text:00011334
.text:00011334 loc_11334                             
--??--> .text:00011334         BL              loc_12E44
.text:00011334 ; END OF FUNCTION CHUNK FOR sub_16144
.text:00011338 ; ---------------------------------------------------------------------------
.text:00011338                 LDR             R1, =aTest_txt ; "\\test.txt"
.text:0001133C                 LDR             R0, =unk_1B000
.text:00011340                 BL              loc_16F84


.text:00012E44 loc_12E44                           
-->.text:00012E44                 BL              loc_11484

.text:00011484 loc_11484                               
.text:00011484                 LDR             R0, =byte_18140
.text:00011488                 LDRB            R0, [R0]
.text:0001148C                 CMP             R0, #0
-?->.text:00011490             BLEQ            loc_114A4
.text:00011494                 LDMFD           SP!, {PC}

.text:000114A4 loc_114A4                               
.text:000114A4                 LDR             R1, =0x30F031F
.text:000114A8                 MOV             R0, #0xC0003
-->.text:000114B0              BL              sub_110E4
.text:000114B4                 LDMFD           SP!, {PC}

.text:000110E4 sub_110E4                               
.text:000110E4                                         
.text:000110E4                 LDR             PC, [R12]
.text:000110E4 ; End of function sub_110E4

Offset 11338 never get executed, we have some loop again.
Where the problem can be?
---
  Guide me God and I`ll find you

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: fpc/arm broken
« Reply #6 on: April 03, 2015, 12:05:13 am »
Well spotted. I forgot to shift the addend before adding it to the relocated value :)

Some of it looked right, but there was an off by 4 error there as you saw. It should work much better now :)

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fpc/arm broken
« Reply #7 on: April 03, 2015, 12:15:21 am »
Hi,

what a fanatic support Laksen.. KUDOZ!
PS: I`m compiling compiler, in couple of minutes I`ll report if everything is OK
---
  Guide me God and I`ll find you

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: fpc/arm broken
« Reply #8 on: April 03, 2015, 12:30:49 am »
Perfect, everything is good now.
Thanks for help!
---
  Guide me God and I`ll find you

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: fpc/arm broken
« Reply #9 on: April 03, 2015, 12:33:15 am »
No problem. Please report it on the fpc bugtracker if you run into any other issues

BeniBela

  • Hero Member
  • *****
  • Posts: 905
    • homepage
Re: fpc/arm broken
« Reply #10 on: April 03, 2015, 04:34:56 pm »
So which would be the most stable revision?

30177 or 30409 ?


Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: fpc/arm broken
« Reply #11 on: April 03, 2015, 05:07:07 pm »
30177 still had the internal assembler from the original patch. It might have more bugs than version in trunk.

I would say trunk is most stable, unless you just use the external assembler and linker(-Xi -Aas).

 

TinyPortal © 2005-2018