[fpc-pascal] Using arm-embedded-fpc

Koenraad Lelong fpascal1 at de-brouwerij.be
Wed Oct 23 11:23:33 CEST 2013


Searching the mail from this list it seems there are a number of people 
that use fpc to compile for arm-embedded.
I would like to do also, but I never managed to get a clean compiler. 
With this I mean I can make a cross-compiler now, but when I use it to 
make a program I get an error at the linking stage.
It is very frustrating that I seem to be the only one experiencing this, 
so I must be doing something wrong. This is what I do :
I have a 'virgin' virtual linux machine, opensuse 12.3, with fpc 2.6.2 
installed. I'm following the wiki :

I have the sources of binutils-2.23.1. There I do :
./configure --target=arm-none-eabi --prefix=/usr 
--program-prefix=arm-embedded- --disable-werror
sudo make install

fpc at linux-npjb:~/binutils-2.23.1> arm-embedded-as -v
GNU assembler version 2.23.1 (arm-none-eabi) using BFD version (GNU 
Binutils) 2.23.1

I have fpc svn 25843 (downloaded today). There I do :

make clean
make buildbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm 
sudo make installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm 

As root I do :

cd /usr/bin
ln -s ../lib/fpc/2.7.1/ppcrossarm ppcrossarm

fpc at linux-npjb:~/src-arm-fpc> fpc -Parm -Tembedded -Wplpc2124 tled
Free Pascal Compiler version 2.7.1 [2013/10/23] for arm
Copyright (c) 1993-2013 by Florian Klaempfl and others
Target OS: Embedded
Compiling tled1.pp
Assembling program
Linking tled1
/usr/bin/arm-embedded-ld: error: no memory region specified for loadable 
section `.note.gnu.build-id'
tled1.pp(54,4) Error: Error while linking
tled1.pp(54,4) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcrossarm returned an error exitcode (normal if you did 
not specify a source file to be compiled)

fpc at linux-npjb:~/src-arm-fpc> cat link.res
     flash : ORIGIN = 0x00000000, LENGTH = 0x00040000
     ram : ORIGIN = 0x40000000, LENGTH = 0x00004000
_stack_top = 0x40004000;
      .text :
     _text_start = .;
     KEEP(*(.init, .init.*))
     *(.text, .text.*)
     *(.rodata, .rodata.*)
     _etext = .;
     } >flash
     .note.gnu.build-id : { *(.note.gnu.build-id) }
     .data :
     _data = .;
     *(.data, .data.*)
     KEEP (*(.fpc .fpc.n_version .fpc.n_links))
     _edata = .;
     } >ram AT >flash
     .bss :
     _bss_start = .;
     *(.bss, .bss.*)
     } >ram
. = ALIGN(4);
_bss_end = . ;
_end = .;

When I do :
fpc at linux-npjb:~/src-arm-fpc> arm-embedded-ld link.res
fpc at linux-npjb:~/src-arm-fpc> ls -l
total 312
-rwxr-xr-x 1 fpc users 357294 okt 23 09:33 a.out
-rw-r--r-- 1 fpc users    867 okt 23 09:31 link.res
-rw-r--r-- 1 fpc users   3164 okt 23 09:31 tled1.o
-rw-r--r-- 1 fpc users   1187 okt 23 08:55 tled1.pp

That seems to work. Dissassembling a.out seems to produce a valid 
assembly source. I also tried this with binutils-2.21.1 with the same 
Is there a way to see what parameters fpc generates to invoke the linker ?

I would be very gratefull when someone can pinpoint my error.


Koenraad Lelong

More information about the fpc-pascal mailing list