Skip to content

[BUG] Undefined stack protection symbols in MicroBlaze portasm.S #1416

@furkanyilmazgtb

Description

@furkanyilmazgtb

Describe the bug
In the MicroBlazeV9 FreeRTOS port, enabling XPAR_MICROBLAZE_USE_STACK_PROTECTION requires portSLR_OFFSET and portSHR_OFFSET to be part of the saved task context layout. In portable/portasm.S, these offsets were used in save/restore macros but were not fully integrated with context size/offset definitions, which can lead to undefined-symbol assembler errors or task-context layout mismatch depending on configuration.

This fix integrates stack-protection offsets into context-size definitions for both 32-bit and __arch64__ builds, and aligns portCONTEXT_SIZE / portMINUS_CONTEXT_SIZE with optional FPU + stack-protection fields.

Target

  • Development board: [MicroBlaze-based custom board]
  • Instruction Set Architecture: [MicroBlaze 32-bit (primary), MicroBlaze 64-bit path also updated]
  • IDE and version: [Vitis / XSCT based flow - 2023.2 Classics]
  • Toolchain and version: [mb-gcc ]

Host

  • Host OS: [Windows 11 Pro 25H2]

To Reproduce

  • Use FreeRTOS v11.3.0 MicroBlaze port with XPAR_MICROBLAZE_USE_STACK_PROTECTION enabled.
  • Build portable/portasm.S path with different combinations of:
    • XPAR_MICROBLAZE_USE_FPU = 0/1
    • __arch64__ defined/undefined

Expected behavior
When stack protection is enabled, SLR/SHR registers must have valid context offsets and context frame size must include these fields consistently for all relevant config combinations (32-bit/64-bit, FPU on/off). Save and restore paths should be layout-compatible and stable.

Screenshots

Image Image

Additional context
Patch summary applied in portable/portasm.S:

  • Added conditional stack-protection offsets and adjusted context size in the same definition block:
    • 32-bit + FPU: portFSR_OFFSET=132, portSLR_OFFSET=136, portSHR_OFFSET=140, portCONTEXT_SIZE=144
    • 32-bit no FPU: portSLR_OFFSET=132, portSHR_OFFSET=136, portCONTEXT_SIZE=140
    • 64-bit + FPU: portFSR_OFFSET=264, portSLR_OFFSET=272, portSHR_OFFSET=280, portCONTEXT_SIZE=288
    • 64-bit no FPU: portSLR_OFFSET=264, portSHR_OFFSET=272, portCONTEXT_SIZE=280
  • Removed duplicate portFSR_OFFSET define in offset section to avoid macro redefinition/confusion.

Link to issue post: https://forums.freertos.org/t/microblaze-compilation-error-when-upgrading-to-freertos-v11-3-0/24994

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions