This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

GNU ARM toolchain v12.2 Beta1: ld include doesn't seem to work?

Hi all…

I'm in the process of porting a firmware project to a newer version of the GNU ARM toolchain, previously this was written for v6 of the toolchain, which is quite dated.  I'm currently doing some testing with v12.2 beta 1 -- probably won't use this in production (I'll likely use 11.3r1), but since the newer release is there, I'll use that to do the initial porting to possibly shake out some bugs that v12 may bring.

One issue I'm hitting is with `ld`… I won't post the _actual_ code being used, but I'll instead post this simple little test case:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
stuartl@vk4msl-ws:/tmp/test$ tail -n +0 *
==> boot.c <==
#include <stdbool.h>
int main(void) {
while (true);
return 0;
}
==> boot.ld <==
INCLUDE "mem.ld"
ENTRY(main)
SECTIONS
{
.reserved_app : ALIGN(4)
{
. = 0x00000000;
application_start = .;
FILL(0xff);
. += LENGTH(APPLICATION) - 1;
BYTE(0xff);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The actual application has two parts that need to be built: one is a boot-loader, and the other is the main application.  To place the parts in the right spots, I use different linker scripts, but they have _common_ sections in their linker scripts, so these are split out into different files and included in the relevant linker script.

In older releases of the toolchain, this worked beautiful:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
stuartl@vk4msl-ws:/tmp/test$ make clean all CROSS_COMPILE=/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-
rm -f boot.o boot.elf boot.map
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gcc -fdata-sections -ffunction-sections -Os -g -mcpu=cortex-m3 -mfloat-abi=soft -mthumb -c -o boot.o boot.c
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gcc -T boot.ld -lc -lgcc -lnosys -Wl,-Map=boot.map -o boot.elf boot.o
stuartl@vk4msl-ws:/tmp/test$ cat boot.map
Archive member included to satisfy reference by file (symbol)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/crt0.o (exit)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-impure.o)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o) (_global_impure_ptr)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-init.o)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/crt0.o (__libc_init_array)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-memset.o)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/crt0.o (memset)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-__call_atexit.o)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o) (__call_exitprocs)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-atexit.o)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-__call_atexit.o) (atexit)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-fini.o)
/opt/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-__call_atexit.o) (__libc_fini_array)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Even the standard Ubuntu 22.04 arm-none-eabi toolchain works:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
stuartl@vk4msl-ws:/tmp/test$ make clean all
rm -f boot.o boot.elf boot.map
arm-none-eabi-gcc -fdata-sections -ffunction-sections -Os -g -mcpu=cortex-m3 -mfloat-abi=soft -mthumb -c -o boot.o boot.c
arm-none-eabi-gcc -T boot.ld -lc -lgcc -lnosys -Wl,-Map=boot.map -o boot.elf boot.o
stuartl@vk4msl-ws:/tmp/test$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Arm Embedded Toolchain 9-2020-q2-update) 9.3.1 20200408 (release)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
stuartl@vk4msl-ws:/tmp/test$ cat boot.map
Archive member included to satisfy reference by file (symbol)
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o)
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/crt0.o (exit)
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-impure.o)
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-exit.o) (_global_impure_ptr)
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-init.o)
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/crt0.o (__libc_init_array)
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/libc.a(lib_a-memset.o)
/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/crt0.o (memset)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

BUT… ARM's latest (beta) toolchain does not like this:

Fullscreen
1
2
3
4
5
6
7
8
9
stuartl@vk4msl-ws:/tmp/test$ make clean all CROSS_COMPILE=/tmp/arm-gnu-toolchain-12.2.mpacbti-bet1-x86_64-arm-none-eabi/bin/arm-none-eabi-
rm -f boot.o boot.elf boot.map
/tmp/arm-gnu-toolchain-12.2.mpacbti-bet1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -fdata-sections -ffunction-sections -Os -g -mcpu=cortex-m3 -mfloat-abi=soft -mthumb -c -o boot.o boot.c
/tmp/arm-gnu-toolchain-12.2.mpacbti-bet1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -T boot.ld -lc -lgcc -lnosys -Wl,-Map=boot.map -o boot.elf boot.o
/tmp/arm-gnu-toolchain-12.2.mpacbti-bet1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld:boot.ld:15: warning: memory region `APPLICATION=0xffffffff' not declared
/tmp/arm-gnu-toolchain-12.2.mpacbti-bet1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld:boot.ld:30: warning: memory region `BOOTLOADER=' not declared
/tmp/arm-gnu-toolchain-12.2.mpacbti-bet1-x86_64-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld:boot.ld:30: syntax error
collect2: error: ld returned 1 exit status
make: *** [Makefile:14: boot.elf] Error 1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Is there something I've missed?

0