1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# A cloned data section keeps its alignment. 5# 6# Plenty of kernel data is aligned for correctness rather than speed: per-CPU 7# variables, anything touched by an aligned vector move, structures padded to 8# own a cacheline. A clone that lands under-aligned either faults on first use 9# or silently shares a line it was laid out to avoid, and neither shows up 10# until the patch is loaded on hardware that cares. 11# 12# Fixed by 2f2600decb30 ("objtool/klp: Fix alignment of cloned data 13# sections"). 14# 15# Covers the same ground as corpus/x86_64/cloned-data-alignment in Joe 16# Lawrence's klp-build unit test corpus. 17 18. "$(dirname "$0")/../lib.sh" 19 20setup 21build_pair data_alignment.c 22 23# The premise: the compiler really did over-align it, and the object is new in 24# the patch so it has to be cloned rather than referenced. 25want="$(in_sections patched.o | sed 's/^ *\[[ 0-9]*\] *//' | 26 awk '$1 == ".data.aligned_data" { print $NF }')" 27[ "$want" = 64 ] || 28 probe_skip "compiler gave .data.aligned_data alignment '$want', not 64" 29has_input_section orig.o .data.aligned_data && 30 fail "fixture put aligned_data in the original; nothing to clone" 31 32run_diff 33assert_section .data.aligned_data 34 35got="$(out_sections | sed 's/^ *\[[ 0-9]*\] *//' | 36 awk '$1 == ".data.aligned_data" { print $NF }')" 37[ "$got" = "$want" ] || 38 fail "cloned .data.aligned_data has alignment $got, expected $want" 39 40pass "cloned data section keeps its alignment" 41