Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLD] powerpc64/powerpc64le incorrect linkage of IFUNC symbols on FreeBSD kernel #57722

Closed
adalava opened this issue Sep 13, 2022 · 2 comments
Closed
Labels
lld:ELF platform:freebsd wontfix Issue is real, but we can't or won't fix it. Not invalid

Comments

@adalava
Copy link
Contributor

adalava commented Sep 13, 2022

On FreeBSD powerpc64 and powerpc64le kernels panic when copyin/copyout symbols are called by external loadable kernel modules (like pfsync) after change https://reviews.freebsd.org/rG47a57144af25a7bd768b29272d50a36fdf2874ba where the IFUNC copyin/copyout functions are in a struct of function pointers.

While debugging LLD I found that the symbols get HAS_DIRECT_RELOC set and the type is changed from STT_GNU_IFUNC to STT_FUNC. A workaround is wrap the calls in a local function (see workaround code in https://reviews.freebsd.org/D36234).
The following tentative also makes a good binary, but it's incorrect and may cause other problems: https://reviews.llvm.org/D133745

You can download LLD reproduce tar from: https://people.freebsd.org/~alfredo/tmp/llvm-freebsd-ppc64-kernel-copyout-ifunc.tar.xz
With readelf -a kernel.full | grep -w copyout on a good binary you should see two entries of type IFUNC while FUNC on the bad binaries.

Thanks!

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 13, 2022

@llvm/issue-subscribers-lld-elf

@MaskRay
Copy link
Member

MaskRay commented Sep 14, 2022

See https://maskray.me/blog/2021-01-18-gnu-indirect-function#address-significance STT_GNU_IFUNC has to be converted to STT_FUNC in this case as satisfy pointer equality. I think FreeBSD has a bug somewhere that incorrectly uses non-GOT-generating non-PLT-generating relocation somewhere. The issue should be discussed on the FreeBSD side.

@MaskRay MaskRay closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2022
@EugeneZelenko EugeneZelenko added the wontfix Issue is real, but we can't or won't fix it. Not invalid label Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lld:ELF platform:freebsd wontfix Issue is real, but we can't or won't fix it. Not invalid
Projects
None yet
Development

No branches or pull requests

4 participants