-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
Description
An ALIGN() directive applied to the LMA of an empty section will influence the LMA of the next non-empty section that follows.
However, when using GCC/ld, in this scenario, the next non-empty section's LMA will begin at the last available LMA address prior to the ALIGN occurirng on the empty section's LMA.
For a simplified example, I modified a sample project from the embedded toolchain.
Changes:
- Add map file generation to the build target of the Makefile -
$(BIN_PATH)/clang $(MICROBIT_TARGET) $(CRT) -g -Xlinker -Map=hello.map -T ../../ldscripts/microbit.ld -o hello.elf $^ - Add the
align_bugsection to/opt/LLVMEmbeddedToolchainForArm-17.0.0-Linux-x86_64/lib/clang-runtimes/arm-none-eabi/armv6m_soft_nofp/lib/picolibcpp.ld

Actual Result: LMA of .data is the aligned LMA of empty section .align_bug
3320 3320 28 4 .except_unordered
3320 3320 0 1 . = ALIGN ( 8 )
3320 3320 28 4 <internal>:(.ARM.exidx)
20000000 3350 0 16 .align_bug
20000000 3350 0 1 . = .
20000000 3350 38 4 .data
20000000 3350 30 4 /tmp/hello-6adfd4.o:(.data)
20000000 3350 4 1 gpio_dir_set
20000004 3354 4 1 uart_starttx
20000008 3358 4 1 uart_txdrdy
Expected Result: LMA of .data is the the address immediately following 0x3320 + 0x28 (LMA of .except_unordered + size of .except_unordered)
3320 3320 28 4 .except_unordered
3320 3320 0 1 . = ALIGN ( 8 )
3320 3320 28 4 <internal>:(.ARM.exidx)
20000000 3348 38 4 .data
20000000 3348 30 4 /tmp/hello-dc4e29.o:(.data)
20000000 3348 4 1 gpio_dir_set
20000004 334c 4 1 uart_starttx
20000008 3350 4 1 uart_txdrdy