On 05.12.2025 23:40, Andrew Cooper wrote: > On 05/12/2025 10:28 pm, Jason Andryuk wrote: >> When linking to create xen-syms, add --gc-sections to garbage collect >> unused stuff. Relies on CONFIG_CC_SPLIT_SECTIONS >> >> We need to add KEEP() to the linker script in assorted places to retain >> appropriate data - especially the arrays created therein. >> >> Something is off though. In a test where memory_add() is unreachable, >> it is still included. I'm not sure, but I am wondering if it's the >> alternatives somehow keeping a reference to it. > > Yes, .altinstructions contains relocations against the origin patch > site, which will cause it to appear to be referenced. The same will be > happening with a bunch of other sections.
We will need to derive helper section names from base section ones. See e.g. HAVE_AS_SECTNAME_SUBST as introduced by "common: honor CONFIG_CC_SPLIT_SECTIONS also for assembly functions", controlling the use of the --sectname-subst asssembler option, to in turn be able to use %S in section names (available from gas 2.26 onwards). I'd like to point out though that for the purpose of "x86/alternatives: allow replacement code snippets to be merged" we may want to avoid extending this to .altinstr_replacement. Jan
