[RFC] ANY linker script syntax for non-contiguous regions

Daniel Thornburgh dthorn@google.com
Tue Feb 6 23:58:39 GMT 2024


I've been working to add a feature for section packing akin to LD's
`--enable-non-contiguous-regions` to LLD. Discussing this[1] revealed a
desire to have an explicit syntax in the linker script, rather than having
a flag globally modify the behavior of wildcard matching and address
layout. I wanted to pop my head in here before implementing anything too
extensively with the hope of arriving at something that could work across
linkers.

I'm currently thinking of something like the existing `SORT_BY_xxx`
modifiers: `ANY(<tag> <wildcard_patterns>)`. This would match input
sections identically as normal, but it would record the set of matched
sections as associated with the given tag. Then, any further instances of
`ANY(<tag>)` without any wildcard patterns would provide locations that the
tagged sections could spill to, as if by a subsequent
`enable-non-contiguous-regions` match. `ANY` refers to the possibility that
any of the tagged sections that fit may appear at that location. (The name
feels weak to me; it comes from a vague reference to an armlink feature
with wildly different semantics. Open for suggestions.)

Using tags avoids introducing a new semantics for wildcard matching; a
section would still always match exactly one wildcard. Accordingly, it
would preserve the ability to use broad wildcards to refer to anything not
yet matched by earlier more specific ones. This in turn should make porting
easier, since linker scripts may be written assuming this. By contrast,
`--enable-non-contigous-regions` makes broad wildcards potential spill
locations for earlier matches, which may not have been intended.

[1] https://discourse.llvm.org/t/rfc-lld-enable-non-contiguous-regions/76513
-- 

Daniel Thornburgh | dthorn@google.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20240206/3f344667/attachment.htm>


More information about the Binutils mailing list