Skip to content

Linker script uses ALIGN oddly #868

@nwf

Description

@nwf

The nrf52_common.ld linker script oddly uses ALIGN when attempting to draw a distinction between the heap and the stack:

.heap :
{
__HeapBase = .;
__end__ = .;
PROVIDE(end = .);
KEEP(*(.heap*))
. = ALIGN(__StackLimit);
__HeapLimit = .;
} > RAM

While GNU binutils has not required ALIGN's argument to be a power of two since 2.15 (contrast 2.12), lld still complains (probably because ALIGN is almost always used with a small power of two) and, besides and more importantly, ALIGN-ment isn't what the linker script is trying to ensure here! It wants . to advance to the lowest stack address -- that is, __StackLimit, and to place the symbol __HeapLimit there.

TL;DR: I think that line should just be . = __StackLimit;, without the ALIGN() (ah, no, that's a divergence between LLVM and GNU interpretations of linker scripts, siiiigh) be . = ABSOLUTE(__StackLimit);.

Does that seem right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions