<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux/tools/objtool/tests/generic/test-switch-rodata.sh, branch stable</title>
<subtitle>WireGuard for the Linux kernel</subtitle>
<id>https://git.zx2c4.com/wireguard-linux/atom/tools/objtool/tests/generic/test-switch-rodata.sh?h=stable</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux/atom/tools/objtool/tests/generic/test-switch-rodata.sh?h=stable'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/'/>
<updated>2026-09-21T09:12:08Z</updated>
<entry>
<title>objtool/klp: Add test for Clang switch jump tables</title>
<updated>2026-09-21T09:12:08Z</updated>
<author>
<name>Song Liu</name>
<email>song@kernel.org</email>
</author>
<published>2026-09-16T18:43:50Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=317cf7bbfa3de0fb61451e9b0b11d20831fb9f9a'/>
<id>urn:sha1:317cf7bbfa3de0fb61451e9b0b11d20831fb9f9a</id>
<content type='text'>
For a dense enough switch Clang emits the targets as a table in
.rodata..Lswitch.table.&lt;function&gt; -- named after the function but not part
of it.  The patched function indexes into that table, so a clone which does
not bring it along jumps through whatever the kernel's copy holds, which
after a patch that changed the switch is the wrong set of targets.  An
indirect jump to a stale address reports nothing at build or load time.

The fixture asserts its own premise twice over, since both halves depend on
what this Clang chose to do: that a table was built rather than a chain of
comparisons, and that the added case actually changed it.

objtool has no switch-specific code -- the table is carried by the general
mechanism for data a cloned function references -- so this guards that
mechanism reaching an easily-mishandled shape rather than a particular
line, and the test says so.  Making the table uncorrelated, the nearest
available sabotage, does not change the outcome.

Assisted-by: Claude:claude-opus-4
Based-on-test-by: Joe Lawrence &lt;joe.lawrence@redhat.com&gt;
Assisted-by: Claude:claude-opus-5
Signed-off-by: Song Liu &lt;song@kernel.org&gt;
Signed-off-by: Josh Poimboeuf &lt;jpoimboe@kernel.org&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Link: https://patch.msgid.link/20260916184351.2720310-58-song@kernel.org
</content>
</entry>
</feed>
