a-lunev edited a comment on issue #3737:
URL:
https://github.com/apache/incubator-nuttx/issues/3737#issuecomment-846600457
Hi @patacongo,
It fails namely here (struct_main.c) on attempt to call the function:
`97 mystruct->pf();`
As you can see from the previous log
```
pf = 0xdcec (vs 0xdcec) PASS
Calling mystruct->pf()
arm_hardfault: PANIC!!! Hard fault: 40000000
```
the called address is even. However, in Thumb mode it must be odd.
I tried to force it to be odd (by | 1) and the hard fault was fixed.
If I understand correctly, the compiler/linker should have initialized "pf"
field of "struct struct_s dummy" to an odd address automatically, however it
did not.
Do you have idea what's wrong?
This is the detailed log how "struct" example was built:
```
...
TEST_ROOT/buildroot/build_arm_nofpu/staging_dir/bin/arm-nuttx-eabi-gcc -c
-fpic -msingle-pic-base -mpic-register=r10 -mno-pic-data-is-text-relative
-fno-builtin -Wall -Wstrict-prototypes -Wshadow -Wundef -Os
-fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer -mcpu=cortex-m3
-mthumb -mfloat-abi=soft -isystem "TEST_ROOT/nuttx/include" -D__NuttX__
-D__KERNEL__ -pipe -I "TEST_ROOT/apps/include" struct_main.c -o struct_main.o
CC: struct_dummy.c
TEST_ROOT/buildroot/build_arm_nofpu/staging_dir/bin/arm-nuttx-eabi-gcc -c
-fpic -msingle-pic-base -mpic-register=r10 -mno-pic-data-is-text-relative
-fno-builtin -Wall -Wstrict-prototypes -Wshadow -Wundef -Os
-fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer -mcpu=cortex-m3
-mthumb -mfloat-abi=soft -isystem "TEST_ROOT/nuttx/include" -D__NuttX__
-D__KERNEL__ -pipe -I "TEST_ROOT/apps/include" struct_dummy.c -o struct_dummy.o
LD: struct_main.o
TEST_ROOT/buildroot/build_arm_nofpu/staging_dir/bin/arm-nuttx-eabi-ld -r -d
-warn-common -o struct.r1 struct_main.o struct_dummy.o
MK: struct.r1
TEST_ROOT/buildroot/build_arm_nofpu/staging_dir/bin/mknxflat -o
struct-thunk.S struct.r1
AS: struct-thunk.S
TEST_ROOT/buildroot/build_arm_nofpu/staging_dir/bin/arm-nuttx-eabi-gcc -c
-fpic -msingle-pic-base -mpic-register=r10 -mno-pic-data-is-text-relative
-fno-builtin -Wall -Wstrict-prototypes -Wshadow -Wundef -Os
-fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer -mcpu=cortex-m3
-mthumb -mfloat-abi=soft -isystem "TEST_ROOT/nuttx/include" -D__NuttX__
-D__KERNEL__ -pipe -I "TEST_ROOT/apps/include" struct-thunk.S -o struct-thunk.o
LD: struct-thunk.o
TEST_ROOT/buildroot/build_arm_nofpu/staging_dir/bin/arm-nuttx-eabi-ld -r -d
-warn-common -T TEST_ROOT/nuttx/binfmt/libnxflat/gnu-nxflat-pcrel.ld
-no-check-sections -o struct.r2 struct_main.o struct_dummy.o struct-thunk.o
LD: struct.r2
TEST_ROOT/buildroot/build_arm_nofpu/staging_dir/bin/ldnxflat -e main -s 2048
-o struct struct.r2
INPUT SECTIONS:
SECT LOW HIGH SIZE
TEXT 00000000 0000026a 0000026a
DATA 00000000 0000001c 0000001c
BSS 0000001c 0000001c 00000000
Entry symbol "main": 00000058 in section ".text"
...
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]