Skip to content

[ATfE] Cherry-pick libc support changes into 22.x branch#730

Merged
voltur01 merged 17 commits intoarm:release/arm-software/22.xfrom
voltur01:cherrypick_libc_support_changes
Feb 20, 2026
Merged

[ATfE] Cherry-pick libc support changes into 22.x branch#730
voltur01 merged 17 commits intoarm:release/arm-software/22.xfrom
voltur01:cherrypick_libc_support_changes

Conversation

@voltur01
Copy link
Contributor

@voltur01 voltur01 commented Feb 20, 2026

This cherry-picks changes relevant to llvmlibc-support from current arm-software into the 22.x release branch:

12a4f2c [ATfE] Document _platform_debug_putc() (#723)
75faad2 [ATfE] Support command line options in LLVM libc (#705)
2ae2b6c [ATfE] Fix libc v7-R no-fpregs attribute build failure (#720)
bc8a58b [ATfE] Provide LLVM libc handlers for hardware and runtime setup (#706)
852e751 [ATfE] Provide debug output handler in LLVM libc crt0
9be5d72 (origin/add_unhosted_exit, add_unhosted_exit) Simplified implementation of exit to avoid issues with privileged assembly instructions
983f37c [ATfE] Provide nohost init and exit in llvmlibc startup code
6859f67 [ATfE] Replace call to abort with __llvm_libc_exit in libc startup code (#678)
a284205 (origin/update_exit_comment, update_exit_comment) [ATfE] Update comment about handling cleanup for exit()
fb865b8 (origin/remove_abort_redefinition, remove_abort_redefinition) [ATfE] Replace call to abort with __llvm_libc_exit in libc startup code
28c43df (origin/use_sys_readc_for_stdin) Merge branch 'arm-software' into use_sys_readc_for_stdin
53e062f (use_sys_readc_for_stdin) Added a comment with rationale and TODO
bbf19b6 (origin/add_semihosting_abort, add_semihosting_abort) Mark internal semihosting function as static
52d1d90 Provide semihosting_call_exit() and add TODO for exit()
99c608d Replace exit() with direct call to __llvm_libc_exit()
07fe14b [ATfE] Use semihosting SYS_READC for stdin with llvm libc
ab08655 [ATfE] Redirect libc abort() to semihosting exit()

voltur01 and others added 16 commits February 20, 2026 11:09
The default libc abort() traps, thus exception handlers under semihosting crash QEMU because of nested exceptions - redirect abort() to exit() instead to cleanly finish execution with QEMU.
Semihosting SYS_READ call on stdin just returns immediately indicating no data was read, thus rendering stdin unusable with QEMU.

SYS_READC blocks and waits for one symbol to be read from the terminal, however Enter key specifically is returned as '\r', thus the special case (that may not generalize well beyond QEMU).
LLVM libc does not provide a way to redefine abort(), thus the local abort() definition in LLVM libc semihosting has to be removed.

Calls to abort() in LLVM libc crt0 replaced with __llvm_libc_exit() which is the LLVM libc defined platform specific exit handler.

This prevents exception handlers from crashing because of the trap instruction in LLVM libc implementation of abort().
…de (arm#678)

LLVM libc does not provide a way to redefine abort(), thus the local
abort() definition in LLVM libc semihosting has to be removed.

Calls to abort() in LLVM libc crt0 replaced with __llvm_libc_exit()
which is the LLVM libc defined platform specific exit handler.

This prevents exception handlers from crashing because of the trap
instruction in LLVM libc implementation of abort().
Provide init and exit handlers for not hosted environments in llvm libc crt0.

Update the documentation accordingly.

Update the UART sample to make use of the symbols provided in crt0 and refine the comments for the remaining symbols related to IO retargeting.
Replace direct call to semihosting WRITEC for debug output of exception details to a platform specific handler: _platform_debug_putc(int c)

Implement the handler in semihosting and provide a placeholder in no-host crt0.
…#706)

Add handlers in LLVM libc startup code that can be overridden by the
user to customize hardware and runtime setup, e.g. provide a custom
exceptions table or such.
After the customization handlers were added in
arm@bc8a58b
the optional no-fpregs attribute collided with the extern "C"
declaration on the handler - this was fixed by creating an extern "C"
block around it.
Add support in LLVM libc startup code to get command line options
(argc/argv) from semihosting.

Provide an empty handler that can be overridden for no-host environment.

Semihosting passes the command line options as one string, thus basic
logic to split it into individual arguments implemented:
- Arguments are split by whitespace.
- Quoted text is copied as-is: "a b c " or 'a b c ' will keep all
spaces. Not closed quote will run till the end of the provided line.
- Escape sequences: \ escapes (copies) the next symbol, unless
  inside single quotes or at the end of the string.
@voltur01 voltur01 requested a review from a team as a code owner February 20, 2026 13:11
dcandler
dcandler previously approved these changes Feb 20, 2026
Add more details about `void _platform_debug_putc(int c)` to the
documentation page.
@voltur01 voltur01 merged commit e90e1fc into arm:release/arm-software/22.x Feb 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants