fpc/arm broken lazarus / 35-Windows CE ---------------------------------------------------------------------- vincococka · 2015-04-02 14:19 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 ---------------------------------------------------------------------- vincococka · 2015-04-02 15:51 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? ---------------------------------------------------------------------- Laksen · 2015-04-02 16:56 I'm here, yes. What command line did you use to build with? ---------------------------------------------------------------------- vincococka · 2015-04-02 18:10 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 ---------------------------------------------------------------------- Laksen · 2015-04-02 18:27 Alright. Found the bug, it should be fixed now. ---------------------------------------------------------------------- vincococka · 2015-04-02 20:54 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? ---------------------------------------------------------------------- Laksen · 2015-04-02 22:05 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 · 2015-04-02 22:15 Hi, what a fanatic support Laksen.. KUDOZ! PS: I`m compiling compiler, in couple of minutes I`ll report if everything is OK ---------------------------------------------------------------------- vincococka · 2015-04-02 22:30 Perfect, everything is good now. Thanks for help! ---------------------------------------------------------------------- Laksen · 2015-04-02 22:33 No problem. Please report it on the fpc bugtracker if you run into any other issues ---------------------------------------------------------------------- BeniBela · 2015-04-03 14:34 So which would be the most stable revision? 30177 or 30409 ? ---------------------------------------------------------------------- Laksen · 2015-04-03 15:07 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).