mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-13 17:38:48 +04:00
iremap is called with BUILD_DIR and with PKG_BUILD_DIR, never with STAGING_DIR. A header taken from the staging directory therefore reaches __FILE__ and the debug information with its absolute path, and the result depends on the directory the tree was built in. Measured in the published snapshot of lantiq/xway: mt76-connac-lib.ko, mt76x02-lib.ko and mt7925-common.ko hold /builder/shared-workdir/build/staging_dir/target-mips_24kc_musl/usr/include/mac80211/net/cfg80211.h That path is __FILE__ in .rodata, so the strip before the package is built cannot reach it and the module ships it. Map STAGING_DIR as well. Keep the staging_dir element in the replacement: the last element of STAGING_DIR and of BUILD_DIR carry the same name, so the bare name would make the two roots indistinguishable. The map of BUILD_DIR does not change, so only a path that leaks today changes. Verified with the target compiler on a header below a mapped directory: -ffile-prefix-map removes the absolute path from both __FILE__ and the debug information, -fmacro-prefix-map removes it from __FILE__ alone. The shipped half is __FILE__, so both variants cover it. A local build of mt76 also holds nine staging paths, but those are debug information: the build directory copy of mt76-connac-lib.ko is 653456 bytes with 13 debug sections and nine such paths, the shipped copy is 84688 bytes with none. They are named here so that the next reader does not take them for the same defect. Signed-off-by: John Crispin <john@phrozen.org>