Skip to content

[ELF][Cheri] Support (/path/to/)libfoo.a:bar.o c18n policy syntax - #814

Open
jrtc27 wants to merge 2 commits into
c18n_policyfrom
c18n_policy-scope-static-lib
Open

jrtc27 wants to merge 2 commits into
c18n_policyfrom
c18n_policy-scope-static-lib

Conversation

@jrtc27

@jrtc27 jrtc27 commented Apr 10, 2026

Copy link
Copy Markdown
Member

This allows for matching only input files pulled in from a static
library.

In theory extending this to support :(/path/to/)bar.o to mean only files
not from static libraries (i.e. on the command line or pulled in by
linker scripts) could be useful, but the priority of the various
combinations becomes less clear, as static libraries (by virtue of being
ar archives) don't permit directories and sidestep that question;
specifically, there is the question of whether :bar.o or /path/to/bar.o
(without an explicit empty scope) is higher priority.

@jrtc27
jrtc27 requested a review from bsdjhb April 10, 2026 22:34
@jrtc27
jrtc27 force-pushed the c18n_policy-scope-static-lib branch from ea21439 to 0bdb2ff Compare April 10, 2026 22:41

@bsdjhb bsdjhb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One further thought I had after we talked about this is if we should accept the archive name alone as the path? E.g. "libfoo.a" or "libfoo*.a" and match on those?

I also wonder if it would be less confusing if we required a scope for archive members. In this way, the globs more readily match against the arguments passed on the command line to lld.

A longer term idea I have is to permit archives to embed a policy file (using some specific filename?) and for such a policy file, it would implicitly only apply file matches to object files contained in the .a. I can think of a way to implement that, but it may not be trivial to ensure that such an embedded policy doesn't contain rules that affect other object files included in a link that aren't from the archive. Still, it might be nice if libc.a contained the policy so static binaries would honor it? (Granted, static binaries don't implement stack isolation today, so....)

jrtc27 and others added 2 commits October 14, 2026 14:23
This allows for matching only input files pulled in from a static
library.

In theory extending this to support :(/path/to/)bar.o to mean only files
not from static libraries (i.e. on the command line or pulled in by
linker scripts) could be useful, but the priority of the various
combinations becomes less clear, as static libraries (by virtue of being
ar archives) don't permit directories and sidestep that question;
specifically, there is the question of whether :bar.o or /path/to/bar.o
(without an explicit empty scope) is higher priority.
…ntax

[ELF][Cheri] Require archive names in c18n policy syntax

For object files which are archive members, require the path of a
file specification to name the archive (static library) rather than
the individual object file.  An archive name can be followed by an
optional suffix (prefixed with a colon) with a glob pattern for
archive members.
@bsdjhb
bsdjhb force-pushed the c18n_policy-scope-static-lib branch from 0bdb2ff to 02c7277 Compare October 16, 2026 20:16
@bsdjhb

bsdjhb commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

So the squash commit makes the changes I suggested of requiring the archive name leaving the member name as an optional suffix. I also ran into a weird issue with scopedPath.str() seeming to be a UAF locally that I resolved by just using a local std::string to "hold" the backing store for a plain StringRef while doing the per-file checks. The priority I use for archive members is "full archive path:" -> "full archive path" -> "base archive path:" -> "base archive path" in decreasing priority. The order of the middle two is debatable, that is a full path more important than fully-scoped or vice versa.

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.

Handle static library inputs (both as a whole and individual object files) in ELF c18n policy language

2 participants