Skip to content

Fix embedded images built with the clang compiler#730

Open
danielinux wants to merge 19 commits intowolfSSL:masterfrom
danielinux:clang-linker
Open

Fix embedded images built with the clang compiler#730
danielinux wants to merge 19 commits intowolfSSL:masterfrom
danielinux:clang-linker

Conversation

@danielinux
Copy link
Copy Markdown
Member

zd21378

Copilot AI review requested due to automatic review settings March 19, 2026 22:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses oversized/sparse embedded images produced when building with clang by adjusting linking and objcopy behavior for clang-based builds.

Changes:

  • Add clang-specific objcopy section filtering to avoid producing huge sparse binary/hex/srec outputs.
  • Switch clang builds to use the GNU linker driver to preserve LMAs in the linker script.
  • Relax clang build warnings around unknown attributes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
test-app/Makefile Introduces clang-specific objcopy flags and applies them to image artifact generation to prevent sparse outputs.
arch.mk Changes clang toolchain linking to use GNU linker driver and adds clang warning suppressions for unknown attributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 23, 2026 17:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 23, 2026 18:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 31, 2026 21:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings April 3, 2026 14:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings April 3, 2026 15:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +5
/* Workaround for GNU ld mishandling AT() on output sections when no input
* object contributes a matching section. Clang does not emit empty .data/.bss
* sections in object files (GCC does), so GNU ld fails to assign the correct
* LMA for the .data output section, producing a huge sparse binary.
* Including this object ensures .data and .bss exist as inputs.
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header comment attributes the sparse-binary issue to “GNU ld”, but Clang builds now force -fuse-ld=lld in arch.mk. If the real failure mode is tied to the linker being used with USE_CLANG=1, consider updating this comment to describe the problem more generally (or name the specific linker/toolchain combination that still needs the workaround) so future maintenance doesn’t incorrectly assume GNU ld is still involved.

Suggested change
/* Workaround for GNU ld mishandling AT() on output sections when no input
* object contributes a matching section. Clang does not emit empty .data/.bss
* sections in object files (GCC does), so GNU ld fails to assign the correct
* LMA for the .data output section, producing a huge sparse binary.
* Including this object ensures .data and .bss exist as inputs.
/* Workaround for the linker used with Clang builds mishandling AT() on
* output sections when no input object contributes a matching section.
* Clang does not emit empty .data/.bss sections in object files (GCC does),
* so the linker can assign the wrong LMA for the .data output section,
* producing a huge sparse binary. Including this object ensures .data and
* .bss exist as inputs.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 3, 2026 16:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +6
/* Workaround for GNU ld mishandling AT() on output sections when no input
* object contributes a matching section. Clang does not emit empty .data/.bss
* sections in object files (GCC does), so GNU ld fails to assign the correct
* LMA for the .data output section, producing a huge sparse binary.
* Including this object ensures .data and .bss exist as inputs.
*/
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new assembly file is missing the project’s standard wolfBoot GPL license header comment that appears at the top of other assembly sources. Add the usual license boilerplate (and any required file-level copyright line) to keep licensing consistent across the codebase.

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +56
inputs.config-file == './config/examples/stm32u5-nonsecure-dualbank.config' ||
inputs.config-file == './config/examples/stm32n567.config'
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Clang rebuild condition includes ./config/examples/stm32n567.config, but that config file is not present in this repository. This makes the workflow inconsistent and will fail if the reusable workflow is ever called with that inputs.config-file value; either add the missing config file or remove/rename this entry to an existing config path.

Suggested change
inputs.config-file == './config/examples/stm32u5-nonsecure-dualbank.config' ||
inputs.config-file == './config/examples/stm32n567.config'
inputs.config-file == './config/examples/stm32u5-nonsecure-dualbank.config'

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 3, 2026 17:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattia-moffa mattia-moffa self-assigned this Apr 3, 2026
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.

3 participants