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

cfi: ld.lld: warning: <internal>:(.eh_frame) is being placed in '.eh_frame' #1227

Closed
dileks opened this issue Dec 28, 2020 · 4 comments
Closed
Labels
[FEATURE] CFI Related to building the kernel with Clang Control Flow Integrity Orphan section An linker orphan section warning [TOOL] lld The issue is relevant to LLD linker

Comments

@dileks
Copy link

dileks commented Dec 28, 2020

CC @samitolvanen @MaskRay

I pulled in cfi-5.10 releases tag on top of Linux v5.10.3.

My LLVM toolchain is version 11.0.1-rc2.

Note: CFI (and LTO) feature requires LLVM=1 and LLVM_IAS=1 to be used and LLVM toolchain >= v11 (see CONFIG_HAS_LTO_CLANG).

In my logs I see (beyond usual known CFI warnings):

+ ld.lld-11 -m elf_x86_64 --thinlto-cache-dir=.thinlto-cache -mllvm -import-instr-limit=5 --emit-relocs --discard-none -z max-page-size=0x200000 --build-id=sha1 -X --orphan-handling=warn --strip-debug -o .tmp_vmlinux.kallsyms1 -T ./arch/x86/kernel/vmlinux.lds --whole-archive vmlinux.o --no-whole-archive
ld.lld-11: warning: <internal>:(.eh_frame) is being placed in '.eh_frame'
+ kallsyms .tmp_vmlinux.kallsyms1 .tmp_vmlinux.kallsyms1.S

+ ld.lld-11 -m elf_x86_64 --thinlto-cache-dir=.thinlto-cache -mllvm -import-instr-limit=5 --emit-relocs --discard-none -z max-page-size=0x200000 --build-id=sha1 -X --orphan-handling=warn --strip-debug -o .tmp_vmlinux.kallsyms2 -T ./arch/x86/kernel/vmlinux.lds --whole-archive vmlinux.o --no-whole-archive .tmp_vmlinux.kallsyms1.o
ld.lld-11: warning: <internal>:(.eh_frame) is being placed in '.eh_frame'
+ kallsyms .tmp_vmlinux.kallsyms2 .tmp_vmlinux.kallsyms2.S

+ ld.lld-11 -m elf_x86_64 --thinlto-cache-dir=.thinlto-cache -mllvm -import-instr-limit=5 --emit-relocs --discard-none -z max-page-size=0x200000 --build-id=sha1 -X --orphan-handling=warn -o vmlinux -T ./arch/x86/kernel/vmlinux.lds --whole-archive vmlinux.o --no-whole-archive .tmp_vmlinux.kallsyms2.o
ld.lld-11: warning: <internal>:(.eh_frame) is being placed in '.eh_frame'

Link: https://github.com/samitolvanen/linux/releases/tag/cfi-5.10

@dileks dileks added [ARCH] x86_64 This bug impacts ARCH=x86_64 [TOOL] lld The issue is relevant to LLD linker [FEATURE] CFI Related to building the kernel with Clang Control Flow Integrity labels Dec 28, 2020
@dileks
Copy link
Author

dileks commented Dec 28, 2020

Feel free to change subject and labels.

@samitolvanen samitolvanen removed the [ARCH] x86_64 This bug impacts ARCH=x86_64 label Dec 28, 2020
@samitolvanen
Copy link
Member

samitolvanen commented Dec 28, 2020

Thanks for filing the issue. I also see this on arm64 builds and with ToT LLVM.

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Jan 1, 2021

These warnings are coming from the linker flag --orphan-handling=warn. It seems the linker scripts being passed after -T maybe don't mention where to place these sections explicitly? Usually we disable .eh_frame via -fno-asynchronous-unwind-tables (https://stackoverflow.com/a/26302715/1027966).

@dileks dileks changed the title cfi-5.10: ld.lld-11: warning: <internal>:(.eh_frame) is being placed in '.eh_frame' cfi: ld.lld-11: warning: <internal>:(.eh_frame) is being placed in '.eh_frame' Jan 4, 2021
@dileks dileks changed the title cfi: ld.lld-11: warning: <internal>:(.eh_frame) is being placed in '.eh_frame' cfi: ld.lld: warning: <internal>:(.eh_frame) is being placed in '.eh_frame' Jan 4, 2021
@samitolvanen
Copy link
Member

samitolvanen commented Feb 26, 2021

As Nathan pointed out in issue #1069, defining SANITIZER_DISCARDS also with CONFIG_CFI_CLANG removes the warning. This is now fixed in the current CFI trees.

hmtheboy154 pushed a commit to hmtheboy154/Darkmatter-kernel that referenced this issue Mar 24, 2021
Clang generates an .eh_frame section with CFI, which produces orphan
section warnings:

ld.lld: warning: <internal>:(.eh_frame) is being placed in '.eh_frame'

Define SANITIZER_DISCARDS to drop .eh_frame also with CFI.

Bug: 145210207
Link: ClangBuiltLinux/linux#1227
Change-Id: I383f1d87920894440a234f8fca56f48119777042
Suggested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
@nathanchance nathanchance added the Orphan section An linker orphan section warning label May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[FEATURE] CFI Related to building the kernel with Clang Control Flow Integrity Orphan section An linker orphan section warning [TOOL] lld The issue is relevant to LLD linker
Projects
None yet
Development

No branches or pull requests

4 participants