Skip to content

Commit b55cd21

Browse files
committed
test-app: add dummy .data and .bss sections when using clang
1 parent 41ee5aa commit b55cd21

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

test-app/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ ifeq ($(USE_CLANG),1)
114114
else
115115
OBJCOPY_IMAGE_FLAGS+=$(CLANG_ARM_OBJCOPY_FLASH_FLAGS_APP)
116116
endif
117+
# Clang doesn't emit empty .data/.bss sections in object files (GCC does).
118+
# GNU ld mishandles AT() for output sections with no matching input sections,
119+
# setting LMA=VMA instead of the specified flash address.
120+
APP_OBJS+=clang_sections.o
117121
endif
118122

119123
ifeq ($(DEBUG_UART),1)

test-app/clang_sections.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* Workaround for GNU ld mishandling AT() on output sections when no input
2+
* object contributes a matching section. Clang does not emit empty .data/.bss
3+
* sections in object files (GCC does), so GNU ld fails to assign the correct
4+
* LMA for the .data output section, producing a huge sparse binary.
5+
* Including this object ensures .data and .bss exist as inputs.
6+
*/
7+
.section .data
8+
.section .bss

0 commit comments

Comments
 (0)