this is my build script… the problem will be somewhere else, but thanks for a try
[code]
set CFLAGS=-Wall -Werror -Os -fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD -std=c99 -Wno-psabi
set LDFLAGS=-nostartfiles -mcpu=cortex-m3 -mthumb -march=armv7 -mfix-cortex-m3-ldrd -msoft-float
rem Build library
!CC! !CFLAGS! -c -Wall -Werror -fpic …/library.c
!CC! !LDFLAGS! -shared -o libbios.so library.o
rem Build example
!CC! !CFLAGS! -S …/main.c
!CC! !CFLAGS! -c …/main.c
!CC! -T …/APP2main.lds !LDFLAGS! -Wl,-dynamic-linker,gloader.1 -Wl,-emain main.o -o !TFILE!_!APP!.elf -lbios -L.
[/code]
When searing this problem over internet “cortex m3 blx gcc”, I found many forums regarding this problem and the cause for issuing “BLX address” was mixing thumb/non thumb libraries. But in my build script I am calling gcc with the same -m settings, so I really don’t know what is the cause of this problem…
library.c (it contains only empty functions for each export)
[code]
#include “library.h”
#undef IMPORT
#define IMPORT(local, remote, ret, args) ret local args
IMPORT(PutPixel, BIOS::LCD::PutPixel, void, (int a, int b, ui16 c)) {}
IMPORT(Print, BIOS::LCD::Print, int, (int a, int b, ui16 c, ui16 d, const char* e)) {return 0;}
IMPORT(GetKeys, BIOS::GetKeys, ui16, ()) {return 0;}
IMPORT(Printf, BIOS::LCD::Printf, int, (int x, int y, unsigned short clrf, unsigned short clrb, const char * format, …) ){return 0;}
[/code]
library.h
[code]
typedef unsigned char u8;
typedef unsigned int ui32;
typedef unsigned int u32;
typedef unsigned short ui16;
typedef unsigned short uc16;
typedef unsigned short u16;
#undef IMPORT
#define IMPORT(local, remote, ret, args) extern ret local args;
IMPORT(PutPixel, BIOS::LCD::PutPixel, void, (int, int, ui16));
IMPORT(Print, BIOS::LCD::Print, int, (int, int, ui16, ui16, const char*));
IMPORT(GetKeys, BIOS::KEY::GetKeys, ui16, ());
IMPORT(Printf, BIOS::LCD::Printf, int, (int x, int y, unsigned short clrf, unsigned short clrb, const char * format, ...) );
[/code]
main.c
</s><i>
</i>#include "library.h"
int main(void)
{
Print(20, 160, 0x0000, 0xffff, "Hello!!!");
return 1;
}
<e>
objdump of resulting ELF:
[code]
bin\APP_2.elf: file format elf32-littlearm
Disassembly of section .text:
20005000 :
20005000: b507 push {r0, r1, r2, lr}
20005002: 4b05 ldr r3, [pc, #20] ; (20005018 <main+0x18>)
20005004: 2014 movs r0, #20
20005006: 9300 str r3, [sp, #0]
20005008: 21a0 movs r1, #160 ; 0xa0
2000500a: 2200 movs r2, #0
2000500c: f64f 73ff movw r3, #65535 ; 0xffff
20005010: f000 e85c blx 200050cc <_ebss+0x1c>
20005014: 2001 movs r0, #1
20005016: bd0e pop {r1, r2, r3, pc}
20005018: 2000501c .word 0x2000501c
2000501c: 6c6c6548 .word 0x6c6c6548
20005020: 2121216f .word 0x2121216f
…
Disassembly of section .plt:
200050b8 <.plt>:
200050b8: e52de004 push {lr} ; (str lr, [sp, #-4]!)
200050bc: e59fe004 ldr lr, [pc, #4] ; 200050c8 <_ebss+0x18>
200050c0: e08fe00e add lr, pc, lr
200050c4: e5bef008 ldr pc, [lr, #8]!
200050c8: 00000064 .word 0x00000064
200050cc: e28fc600 add ip, pc, #0, 12
200050d0: e28cca00 add ip, ip, #0, 20
200050d4: e5bcf064 ldr pc, [ip, #100]! ; 0x64
[/code]