Hi, I've a problem with a array of void*, with different versions of arm-elf-gcc. Tried it with 4.3.1 and with current HEAD 4.4.0 from CVS.. Problem seems to exists von both versions. I've created a small example of it:
---- snip ----
void a(void);
void (**v)(void) = { &a };
int main()
{
v[0]();
return 0;
}
void a(void) { }
---- snip ----
I compiled it for cortex-m3 and if I look at the created binary with objdump,
I see, the following for v:
---- snip ----
a.out: file format elf32-littlearm
000118d0 <v>:
118d0: 0000819d .word 0x0000819d
---- snip ----
but the problem is, that the function a is located at 0x819c and not 0x819...
---- snip ----
a.out: file format elf32-littlearm
00008180 <main>:
8180: b580 push {r7, lr}
8182: af00 add r7, sp, #0
8184: f641 03d0 movw r3, #6352 ; 0x18d0
8188: f2c0 0301 movt r3, #1 ; 0x1
818c: 681b ldr r3, [r3, #0]
818e: 681b ldr r3, [r3, #0]
8190: 4798 blx r3
8192: f04f 0300 mov.w r3, #0 ; 0x0
8196: 4618 mov r0, r3
8198: 46bd mov sp, r7
819a: bd80 pop {r7, pc}
0000819c <a>:
819c: b480 push {r7}
819e: af00 add r7, sp, #0
81a0: 46bd mov sp, r7
81a2: bc80 pop {r7}
81a4: 4770 bx lr
81a6: 46c0 nop (mov r8, r8)
---- snip ----
Here is the output of the compiler call (arm-elf-gcc -v -save-temps)
---- snip ----
Using built-in specs.
Target: arm-elf
Configured with: ../../gcc/configure --target=arm-elf --with-cpu=cortex-m3
--with-tune=cortex-m3 --with-mode=thumb --with-float=soft
--enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib
--disable-shared --enable-newlib -enable-multilib --disable-threads
--enable-sjlj-exceptions --enable-libstdcxx-allocator=malloc --disable-libssp
Thread model: single
gcc version 4.4.0 20081212 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-mcpu=cortex-m3' '-mfloat-abi=soft'
'-mthumb'
/usr/local/libexec/gcc/arm-elf/4.4.0/cc1 -E -quiet -v -imultilib thumb
-D__USES_INITFINI__ main.c -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
-fpch-preprocess -o main.i
ignoring nonexistent directory
"/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/arm-elf/4.4.0/include
/usr/local/lib/gcc/arm-elf/4.4.0/include-fixed
/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-mcpu=cortex-m3'
'-mfloat-abi=soft' '-mthumb'
/usr/local/libexec/gcc/arm-elf/4.4.0/cc1 -fpreprocessed main.i -quiet
-dumpbase main.c -mcpu=cortex-m3 -mfloat-abi=soft -mthumb -auxbase main
-version -o main.s
GNU C (GCC) version 4.4.0 20081212 (experimental) (arm-elf)
compiled by GNU C version 4.3.2, GMP version 4.2.4, MPFR
version 2.3.2.
GGC heuristics: --param ggc-min-expand=30 --param
ggc-min-heapsize=4096
Compiler executable checksum:
2f7f6a906212efe6d27971bc21b468e4
main.c:4: warning: initialization from incompatible
pointer type
COLLECT_GCC_OPTIONS='-v' '-save-temps'
'-mcpu=cortex-m3' '-mfloat-abi=soft' '-mthumb'
/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/bin/as -v -mcpu=cortex-m3
-mfloat-abi=soft -o main.o main.s
GNU assembler version 2.19 (arm-elf) using BFD
version (GNU Binutils) 2.19
COMPILER_PATH=/usr/local/libexec/gcc/arm-elf/4.4.0/:/usr/local/libexec/gcc/arm-elf/4.4.0/:/usr/local/libexec/gcc/arm-elf/:/usr/local/lib/gcc/arm-elf/4.4.0/:/usr/local/lib/gcc/arm-elf/:/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/bin/
LIBRARY_PATH=/usr/local/lib/gcc/arm-elf/4.4.0/thumb/:/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/lib/thumb/:/usr/local/lib/gcc/arm-elf/4.4.0/:/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps'
'-mcpu=cortex-m3' '-mfloat-abi=soft' '-mthumb'
/usr/local/libexec/gcc/arm-elf/4.4.0/collect2 -X
/usr/local/lib/gcc/arm-elf/4.4.0/thumb/crti.o
/usr/local/lib/gcc/arm-elf/4.4.0/thumb/crtbegin.o
/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/lib/thumb/crt0.o
-L/usr/local/lib/gcc/arm-elf/4.4.0/thumb
-L/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/lib/thumb
-L/usr/local/lib/gcc/arm-elf/4.4.0
-L/usr/local/lib/gcc/arm-elf/4.4.0/../../../../arm-elf/lib main.o --start-group
-lgcc -lc --end-group /usr/local/lib/gcc/arm-elf/4.4.0/thumb/crtend.o
/usr/local/lib/gcc/arm-elf/4.4.0/thumb/crtn.o
---- snip ----
What am I doing wrong? Or is there a bug in the compiler/linker ?
I get the same for every fp which I add to the array. It the always hold the
functions address +1.
Whats also interesting is, that if I add fp-1 to the array initializer, I get
the correct result,
for example for a() I get 0x819b...
Thnx and regards
Markus
pgpLevuI2SYX9.pgp
Description: PGP signature
