Skip to content

gk7206v100: no second .init.plt in the relinked modules - #307

Merged
dimerr merged 2 commits into
mainfrom
gk7206v100-no-dup-plt
Nov 18, 2026
Merged

dimerr merged 2 commits into
mainfrom
gk7206v100-no-dup-plt

Conversation

@dimerr

@dimerr dimerr commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Every open_*.ko of gk7206v100 prints on load sysfs: cannot create duplicate filename '/module/open_common/sections/.init.plt' plus a stack dump (sysfs_warn_dup from load_module), one per module, ~30 per boot (seen on a GK7206V11A running nightly-20261116).

Cause: the XMedia SDK built its xm_*.ko with CONFIG_ARM_MODULE_PLTS, so each kept the 1-byte .plt / .init.plt placeholders from the kernel's module.lds; ko2obj.sh passed them into kernel/obj/gk7206v100, and relinking adds module.lds' own .init.plt (flags A) beside the blob's (WA) — they don't merge. gk7206v100 is the only family whose blobs have them.

  • scripts/ko2obj.sh: also --remove-section=.plt --remove-section=.init.plt.
  • The 52 gk7206v100 blobs (log, nolog) regenerated from the SDK's multi/{log,nolog} xm_*.ko (the old script reproduces the committed blobs from them byte for byte). Code and data sections unchanged; only the two placeholders removed (no relocation refers to them).

Checked: ld -r -T with a module.lds holding .plt/.init.plt gives 2 .init.plt for the old blob, 1 for the new. Not yet boot-tested with a rebuilt firmware.

Every open_*.ko of gk7206v100 printed, on load,
  sysfs: cannot create duplicate filename '/module/open_common/sections/.init.plt'
followed by a stack dump (sysfs_warn_dup from load_module), one per
module, about 30 a boot. The modules carried two .init.plt sections: the
XMedia SDK built its xm_*.ko with CONFIG_ARM_MODULE_PLTS, so each kept the
1-byte .plt / .init.plt placeholders of the kernel's module.lds, and
ko2obj.sh passed them through into kernel/obj/gk7206v100. Relinking adds
module.lds' own .init.plt (flags A) beside the blob's (WA); the two do not
merge. gk7206v100 is the only family whose blobs have them.

ko2obj.sh now removes .plt and .init.plt, as it removes .modinfo and
.note.Linux. The 52 blobs (log and nolog) are regenerated from the SDK's
multi/{log,nolog} xm_*.ko, from which the old script reproduces the
committed blobs byte for byte. .text, .data, .rodata, .init.text and
.exit.text are unchanged; only the two placeholders are gone (they hold
nothing but their section and $d symbols, and no relocation refers to
them). Linked against a module.lds with .plt / .init.plt, a blob now gives
one of each; before, two .init.plt.

Co-authored-by: OpenIPC AI team <ai@openipc.org>
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Remove duplicate ARM PLT placeholders from relinked modules

🐞 Bug fix 🕐 20-40 Minutes

Grey Divider

AI Description

• Strip vendor PLT placeholders before relinking to prevent duplicate .init.plt sections and
 module-load warnings.
• Apply the fix in the shared conversion script; the PR reports regenerated gk7206v100 log and nolog
 blobs.
Merge Risk 🟡 Medium

Evidence: Partial. The provider did not establish the exact full-PR diff revisions. Excluded changed files: kernel/obj/gk7206v100/log/acomm.o, kernel/obj/gk7206v100/log/adec.o, kernel/obj/gk7206v100/log/aenc.o, kernel/obj/gk7206v100/log/ai.o, kernel/obj/gk7206v100/log/aio.o, kernel/obj/gk7206v100/log/ao.o, kernel/obj/gk7206v100/log/chnl.o, kernel/obj/gk7206v100/log/cipher_drv.o, kernel/obj/gk7206v100/log/common.o, kernel/obj/gk7206v100/log/fb.o, kernel/obj/gk7206v100/log/h264e.o, kernel/obj/gk7206v100/log/h265e.o, kernel/obj/gk7206v100/log/isp.o, kernel/obj/gk7206v100/log/ive.o, kernel/obj/gk7206v100/log/jpege.o, kernel/obj/gk7206v100/log/npu.o, kernel/obj/gk7206v100/log/pm.o, kernel/obj/gk7206v100/log/rc.o, kernel/obj/gk7206v100/log/region.o, kernel/obj/gk7206v100/log/tde.o, kernel/obj/gk7206v100/log/vedu.o, kernel/obj/gk7206v100/log/venc.o, kernel/obj/gk7206v100/log/vgs.o, kernel/obj/gk7206v100/log/vi.o, kernel/obj/gk7206v100/log/vo.o, kernel/obj/gk7206v100/log/vpss.o, kernel/obj/gk7206v100/nolog/acomm.o, kernel/obj/gk7206v100/nolog/adec.o, kernel/obj/gk7206v100/nolog/aenc.o, kernel/obj/gk7206v100/nolog/ai.o, kernel/obj/gk7206v100/nolog/aio.o, kernel/obj/gk7206v100/nolog/ao.o, kernel/obj/gk7206v100/nolog/chnl.o, kernel/obj/gk7206v100/nolog/cipher_drv.o, kernel/obj/gk7206v100/nolog/common.o, kernel/obj/gk7206v100/nolog/fb.o, kernel/obj/gk7206v100/nolog/h264e.o, kernel/obj/gk7206v100/nolog/h265e.o, kernel/obj/gk7206v100/nolog/isp.o, kernel/obj/gk7206v100/nolog/ive.o, kernel/obj/gk7206v100/nolog/jpege.o, kernel/obj/gk7206v100/nolog/npu.o, kernel/obj/gk7206v100/nolog/pm.o, kernel/obj/gk7206v100/nolog/rc.o, kernel/obj/gk7206v100/nolog/region.o, kernel/obj/gk7206v100/nolog/tde.o, kernel/obj/gk7206v100/nolog/vedu.o, kernel/obj/gk7206v100/nolog/venc.o, kernel/obj/gk7206v100/nolog/vgs.o, kernel/obj/gk7206v100/nolog/vi.o, ... and 2 more files. The report lists 15 more gaps.

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed script is a shared conversion boundary for finished vendor .ko files.
  • The gk7206v100 and hi3536dv100 configurations both describe the same end-to-end behavior: convert a vendor module into a relinkable object, link it with a wrapper, and expose its init/exit entry points as the resulting kernel module.
  • These are platform variants of one bounded vendor-module integration rather than separate technical-layer capabilities.
Sources

scripts/ko2obj.sh[1-5]

#!/bin/sh
# ko2obj.sh -- turn a complete vendor .ko into a relinkable module object
#
# Usage: scripts/ko2obj.sh <objcopy> <prefix> <in.ko> <out.o>
#   e.g. scripts/ko2obj.sh arm-linux-gnueabi-objcopy gk7206 xm_vi.ko vi.o

scripts/ko2obj.sh[89-104]

# .plt / .init.plt are the 1-byte placeholders a module built with
# CONFIG_ARM_MODULE_PLTS gets from the kernel's module.lds. Relinked here,
# the kernel's module.lds adds its own, with other flags, so the .ko would
# carry two .init.plt: "sysfs: cannot create duplicate filename
# '/module/<m>/sections/.init.plt'" and a stack dump on every load.
# shellcheck disable=SC2086 # $syms is a list of options
"$OBJCOPY" $syms \
	--rename-section .gnu.linkonce.this_module=.data.vendor_this_module \
	--weaken-symbol=__this_module \
	--remove-section=.modinfo \
	--remove-section=.note.Linux \
	--remove-section=.plt \
	--remove-section=.init.plt \
	--redefine-sym init_module=_${PREFIX}_${mod}_init \
	--redefine-sym cleanup_module=_${PREFIX}_${mod}_exit \
	"$IN" "$OUT"
Behavioral complexity 🟡 Medium 🧩 Compatibility cases, Data transformation

  • Before: the conversion already performed a sequence of format and symbol transformations on finished vendor .ko files, while retaining sections needed by the relinked module.
  • After: it additionally deletes .plt and .init.plt from every converted input.
  • New correctness condition: the removal must be valid for each supported vendor/kernel/toolchain combination and must leave the wrapper-linked module with exactly the PLT sections expected by the target kernel's module.
  • This introduces a compatibility interaction between the input SDK's ARM module layout and the target kernel's module.lds output; it is more than a direct value mapping because retaining versus removing these sections changes link/load metadata and potentially executable relocation support.
  • The script's comment identifies the intended duplicate-section failure mode, but the absence of per-input validation leaves the compatibility condition as an assumption.
Sources

scripts/ko2obj.sh[89-104]

# .plt / .init.plt are the 1-byte placeholders a module built with
# CONFIG_ARM_MODULE_PLTS gets from the kernel's module.lds. Relinked here,
# the kernel's module.lds adds its own, with other flags, so the .ko would
# carry two .init.plt: "sysfs: cannot create duplicate filename
# '/module/<m>/sections/.init.plt'" and a stack dump on every load.
# shellcheck disable=SC2086 # $syms is a list of options
"$OBJCOPY" $syms \
	--rename-section .gnu.linkonce.this_module=.data.vendor_this_module \
	--weaken-symbol=__this_module \
	--remove-section=.modinfo \
	--remove-section=.note.Linux \
	--remove-section=.plt \
	--remove-section=.init.plt \
	--redefine-sym init_module=_${PREFIX}_${mod}_init \
	--redefine-sym cleanup_module=_${PREFIX}_${mod}_exit \
	"$IN" "$OUT"
Potential damage 🟡 Medium 🩹 Temporary loss

  • The concrete affected capability is availability of the converted vendor kernel driver.
  • A bad conversion can prevent the wrapper module from loading or make the driver unusable.
  • The likely recovery is to regenerate the object with a corrected conversion rule and rebuild/redeploy the module; the source provides no evidence of persistent application data corruption or an external irreversible effect.
  • The duplicate-section motivation supports the intended compatibility fix, but the input-section invariant is not mechanically checked.
  • Revert or correct the conversion script, rerun it for affected vendor .ko inputs, rebuild the wrapper modules, and redeploy them.
  • Existing failed module loads are recoverable after replacement; any runtime service interruption lasts until the module is restored.
  • No automatic repair worker or state-repair mechanism is present or evidenced.
Sources

scripts/ko2obj.sh[89-104]

# .plt / .init.plt are the 1-byte placeholders a module built with
# CONFIG_ARM_MODULE_PLTS gets from the kernel's module.lds. Relinked here,
# the kernel's module.lds adds its own, with other flags, so the .ko would
# carry two .init.plt: "sysfs: cannot create duplicate filename
# '/module/<m>/sections/.init.plt'" and a stack dump on every load.
# shellcheck disable=SC2086 # $syms is a list of options
"$OBJCOPY" $syms \
	--rename-section .gnu.linkonce.this_module=.data.vendor_this_module \
	--weaken-symbol=__this_module \
	--remove-section=.modinfo \
	--remove-section=.note.Linux \
	--remove-section=.plt \
	--remove-section=.init.plt \
	--redefine-sym init_module=_${PREFIX}_${mod}_init \
	--redefine-sym cleanup_module=_${PREFIX}_${mod}_exit \
	"$IN" "$OUT"
Assessed commit b5ac092 > Snapshot assessment: the current PR revision could not be verified.
Diagram

graph TD
  A["Vendor modules"] --> B["ko2obj.sh"] --> C["Relinkable objects"] --> D["Kernel relink"] --> E["Loaded modules"]
  F["module.lds"] --> D
Loading
High-Level Assessment

Removing unused vendor placeholders during conversion addresses the duplication at its source while leaving the kernel linker script responsible for the final sections. Changing the linker script instead would affect the broader module build.

Files changed (1) +7 / -0

Bug fix (1) +7 / -0
ko2obj.shStrip vendor .plt and .init.plt placeholders +7/-0

Strip vendor .plt and .init.plt placeholders

• Adds objcopy removal options for both ARM PLT placeholder sections and documents why retaining them causes duplicate .init.plt warnings after relinking. This is the only file present in the supplied unified diff; the reported regenerated blobs are not shown there.

scripts/ko2obj.sh

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Other chips' relinked modules could lose real PLT stubs ✓ Resolved
Description
The new --remove-section=.plt and --remove-section=.init.plt run unconditionally for every
input, so any .ko that carries non-placeholder PLT code loses it with no check. Calls routed
through those stubs would then resolve to nothing, and this would surface as a load or runtime
failure on that chip, not at build time.


Informational

2. Script header omits the new placeholder removal ✓ Resolved
Description
The header comment lists each section the script drops (.modinfo, .note.Linux) and explains why,
but the new .plt and .init.plt removal is documented only in an inline comment further down. A
later maintainer reading the header will not learn that these sections are stripped.

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

… say so up top

Review on #307: the removal applied to any module. Drop each only when it
is what CONFIG_ARM_MODULE_PLTS' module.lds leaves -- at most 1 byte, with
no relocation section of its own -- and stop with an error otherwise, so
real PLT stubs are never discarded. The explanation moves to the header,
beside the other sections the script drops. The 52 gk7206v100 blobs come
out byte for byte the same; a .ko with a 16-byte .plt is refused.

Co-authored-by: OpenIPC AI team <ai@openipc.org>
@dimerr

dimerr commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Qodo review, both addressed in 31a68de:

  1. The removal is now guarded: .plt / .init.plt are dropped only when each is ≤ 1 byte with no relocation section of its own (the module.lds placeholder); otherwise ko2obj.sh stops with an error, so real PLT stubs are never discarded. Modules without the sections (every other family) are unaffected. Checked: the 52 gk7206v100 blobs regenerate byte for byte; a .ko with a 16-byte .plt is refused.
  2. The header now describes the removal, its reason, and the assumption.

@dimerr
dimerr merged commit 5a18160 into main Nov 18, 2026
37 checks passed
@dimerr
dimerr deleted the gk7206v100-no-dup-plt branch November 18, 2026 05:44
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.

1 participant