Page 1 of 1

Linking errors with BFD assertion fail

Posted: Sat Mar 04, 2017 10:35 am
by iamblwb
I tried porting some codes to ESP32, but I encountered a lot of BFD assertions during code linking.
This is the only link error, no other error message appears.
I also downloaded and checked the source code for binutils-2.25.1, but I can’t see any assertion at line 8316 in elf32-xtensa.c
What is the meaning of this link error?
How to fix this error?
Please kindly give me advice.
Thanks

Code: Select all

LD my-esp32.elf
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
.
.
.
.
/esp/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld: BFD (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 2.25.1 assertion fail /Users/ivan/e/ESPTools/crosstool-NG/.build/src/binutils-2.25.1/bfd/elf32-xtensa.c:8316
collect2: error: ld returned 1 exit status

Re: Linking errors with BFD assertion fail

Posted: Sat Mar 04, 2017 11:02 am
by ESP_igrr
Could you please provide some code to help us reproduce this issue?

Re: Linking errors with BFD assertion fail

Posted: Mon Mar 06, 2017 6:27 am
by iamblwb
Please check the attachment below.
Actually, the purpose is to simply test jerryscript.

Here are the steps to build the code:
1. Extract the attached file to the template application
2. Get jerryscript from github and replace it to components/jerryscript
https://github.com/jerryscript-project/jerryscript
3. make app and you will see that link error
my-esp32.zip
(18.56 KiB) Downloaded 593 times

Re: Linking errors with BFD assertion fail

Posted: Mon Mar 06, 2017 6:44 am
by ESP_igrr
For the project you have attached, compilation fails with the following message:

Code: Select all

/private/tmp/my-esp32/main/./main.c:4:25: fatal error: jerryscript.h: No such file or directory
I couldn't reproduce the BFD assertion error.

Re: Linking errors with BFD assertion fail

Posted: Mon Mar 06, 2017 7:22 am
by iamblwb
Sorry, I updated the attachment again and slightly modified the following steps.
Please ignore the previous one and use the new attachment and steps to build the code.

1. Extract the attachment to the template application
2. Get jerryscript from github and copy all files/directories to components/jerryscript
https://github.com/jerryscript-project/jerryscript
e.g.
/cmake will be copied to /my-esp32/components/jerryscript/cmake
/jerry-core will be copied to /my-esp32/components/jerryscript/jerry-core
and so on

3. make the application and you will see the link error
my-esp32_v1.zip
(8.04 KiB) Downloaded 574 times

Re: Linking errors with BFD assertion fail

Posted: Mon Mar 06, 2017 8:16 am
by ESP_igrr
Thanks, I can now reproduce the issue. Unfortunately I don't have a slightest idea what it may be caused by.
Until we figure out the cause, you may try this jerryscript port by Neil Kolban: https://github.com/nkolban/jerryscript-esp32

Re: Linking errors with BFD assertion fail

Posted: Mon Mar 06, 2017 9:22 am
by iamblwb
Thank you for the information.
In fact, before post this issue, I have tried to build kolban’s jerryscript, but unfortunately still get the same error.
Kolban’s code seems to be used for private use, so he did not release the jerryscript parts for public.
https://github.com/nkolban/jerryscript-esp32/issues/1

As you can see jerryscript in his github is empty, does not include the corresponding build script, so I still have to implement this part by myself.
https://github.com/nkolban/jerryscript- ... components

Also I have tried to modify the script in jerryscript official release for target esp8266 to fit esp32 build environment, but magically I still get the same error...

In addition, for you reference, I can reproduce this issue in all these conditions.
OSX/Linux, esp-idf 1.0/esp-idf 2.0, jerrryscript 1.0 or the current main trunk.

Re: Linking errors with BFD assertion fail

Posted: Tue Mar 14, 2017 5:19 am
by xu.zengx
replace -Og -ggdb for -Os

Re: Linking errors with BFD assertion fail

Posted: Tue Mar 14, 2017 12:14 pm
by iamblwb
Thanks for your advice.
In this case it seems esp32 linker has issue with debug build.
Sometimes we still need debug build for further debugging...