Skip to content

Conversation

@tejlmand
Copy link
Contributor

Cherry-pick of: 88970

This PR fixes warnings and handling happening with lld.

First commit fixes the warning:

ld.lld: warning: <internal>:(.eh_frame) is being placed in '.eh_frame'

Zephyr doesn't need the .eh_frame for C code and even discards the section when converting the elf to bin / hex.
gcc/ld per default discards the section, so there is no reason we should keep it for lld.

Second commit fixes the warning:

ld.lld: warning: ignoring memory region assignment for non-allocatable section '.last_section'

This is not just a warning but also results in the LONG(<val>) command inside the linker script to be ignored by lld.
Result is that the last section id is missing in the final output.

To ensure correct and identical behavior between ld and lld, the last section id is now linked into the final image through C code.

Discard the eh_frame section when C++ exceptions are disabled.

In principle the eh_frame may be used for other purposes such as
backtracing when linking C programs, then Zephyr compiles each source
file with '-fno-asynchronous-unwind-tables', thus keeping the eh_frame
in the elf output just takes up space.

When using gcc/ld, then the eh_frame is generally generally discarded
per default, however for clang/lld it will be included but give a
warning that the section is auto-placed.

Some platforms already discards the eh_frame, so unify this for all
targets.

As eh_frame is now discarded in linker scripts then post processing step
of removing the section during hex or bin conversion can also be
removed.

Upstream PR #: 88970

Signed-off-by: Torsten Rasmussen <[email protected]>
Move creation of last section id from ld linker script LONG() usage to
C code with last section attribute.

The use of `LONG()` works correctly with ld but lld emits a warning
because .last_section section is not allocated as there are no matching
input sections and discards the `LONG()` call, meaning the last section
identifier will not be present in the flash.
> ld.lld: warning: ignoring memory region assignment for
>                             non-allocatable section '.last_section'

Placing the last section id in `.last_section` in C code makes lld
allocate the memory for the id and thereby create the output section
with the correct output.

Upstream PR #: 88970

Signed-off-by: Torsten Rasmussen <[email protected]>
@sonarqubecloud
Copy link

@carlescufi carlescufi merged commit 3e0ce76 into nrfconnect:v4.0.99-ncs1-branch Apr 23, 2025
21 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