-
Notifications
You must be signed in to change notification settings - Fork 15
Cannot find symbol for section 2: .text. #981
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
Comments
Steps to reproduce (from #986):
|
I did an integrated-as build and specifically added CFLAGS_.o += -no-integrated-as to the relevant Makefile's for init/initramfs.o and kernel/elfcore.o, and got through the rest of the build, so at least for my configuration, those are the only 2 objects this issue happens with. |
I assume something like this also needs to be done for recordmcount to fix this? |
Just to clarify: |
yeah. |
I switched over to use |
I also ran into this with A random example, compiled with
Objtool fails here because
Edit: OK, my issue looks similar to issue #669, but just in a different part of objtool. Specifically, the new static call processing code and the proposed mcount patch both depend on section symbols, so if either of these occur in a section for which a symbol is missing, objtool is going to segfault. This doesn't appear to be a problem with static calls right now (or we would have noticed it), but the mcount patch triggers this quite often. I fixed this in commit 54d837e for now. |
It sounds like CrOS is hitting this now trying to move to LLVM_IAS=1: https://bugs.chromium.org/p/chromium/issues/detail?id=1148073 cc @jcai19 |
With defconfig+FUNCTION_TRACER, I see this in: init/initramfs.o Sami, I think 54d837e no longer applies on linux-next? |
May I know what dependencies are needed to back port 0271fa5 and 54d837e into 5.4? While trying to test them on 5.4, I realized there were many dependencies I needed to cherry-pick/back-port in order to apply these two patches cleanly. For example, 0271fa5 seems to be based on upstream commit 0f1441b44e823a74f3f3780902a113e07c73fbf6, which is not in 5.4 yet, but I could not cherry-pick it into stable/linux-5.4.y branch cleanly as its dependencies were also missing.
Just to be clear, does that mean 0271fa5 and 54d837e are not enough to fix this issue? Thanks. |
After actually looking at the CrOS bug, I'm guessing it's the same as the original recordmcount issue and these objtool patches are not going to help here. Both issues have the same root cause though, Clang not always generating section symbols, but you'll need to fix this in recordmcount instead. |
I think @arndb just sent patches for this that got picked up by akpm: https://lore.kernel.org/lkml/[email protected]/ |
The patches I sent just work around the problem by avoiding the weak functions in those files, the bug is still there and could show up any time another file has only weak functions in the .text section. |
With these patches I was able to build and boot an x86_64 kernel with LLVM=1 and LLVM_IAS=1 |
Both patches in
|
Looks like the PowerPC folks are getting bit by this too: @emojifreak reported issues with
Without
|
…elocations[_add] kexec_load_purgatory() can fail for many reasons - there is no need to print an error when encountering unsupported relocations. This solves a build issue on powerpc with binutils v2.36 and newer [1], and likely also with the clang integrated assembler [2]. Since commit d1bcae833b32f1 ("ELF: Don't generate unused section symbols") [3], binutils started dropping section symbols that it thought were unused. This isn't an issue in general, but with kexec_file.c, gcc is placing kexec_arch_apply_relocations[_add] into a separate .text.unlikely section and the section symbol ".text.unlikely" is being dropped. Due to this, recordmcount is unable to find a non-weak symbol in .text.unlikely to generate a relocation record against. Dropping pr_err() calls results in these functions being left in .text section, enabling recordmcount to emit a proper relocation record. [1] linuxppc/issues#388 [2] ClangBuiltLinux#981 [3] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d1bcae833b32f1 Signed-off-by: Naveen N. Rao <[email protected]>
There is a new instance of this problem after commit dbe69b299884 ("bpf: Fix dispatcher patchable function entry to 5 bytes nop") for certain configurations:
|
linuxppc/issues#388 alludes to this issue. Looks like binutils reverted dropping section symbols just for ppc: bminor/binutils-gdb@c09c8b4 cc @MaskRay |
That's annoying :/ for what it's worth, I have seen that error on i386 as well, so it is not just powerpc that is affected by this. I think diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index e9e95c790b8e..233836893fd8 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -744,6 +744,7 @@ config FTRACE_MCOUNT_USE_RECORDMCOUNT
depends on !FTRACE_MCOUNT_USE_CC
depends on !FTRACE_MCOUNT_USE_OBJTOOL
depends on FTRACE_MCOUNT_RECORD
+ depends on !AS_IS_LLVM
config TRACING_MAP
bool |
While that diff stops the build error because it disables the use of recordmcount, it does not prevent ftrace from being selected altogether, which may lead to further reports of ftrace not working, despite being selected. We might be able to fix that error in a similar manner as Arnd's previous patches but I am not sure how to go about that... |
More specifically, I only tried removing diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 00127abd89ee..4145939bbb6a 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -389,7 +389,7 @@ static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,
return ret;
}
-int __init bpf_arch_init_dispatcher_early(void *ip)
+int __init_or_module bpf_arch_init_dispatcher_early(void *ip)
{
const u8 *nop_insn = x86_nops[5];
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 0566705c1d4e..4aa7bde406f5 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -971,7 +971,7 @@ struct bpf_trampoline *bpf_trampoline_get(u64 key,
struct bpf_attach_target_info *tgt_info);
void bpf_trampoline_put(struct bpf_trampoline *tr);
int arch_prepare_bpf_dispatcher(void *image, void *buf, s64 *funcs, int num_funcs);
-int __init bpf_arch_init_dispatcher_early(void *ip);
+int __init_or_module bpf_arch_init_dispatcher_early(void *ip);
#define BPF_DISPATCHER_INIT(_name) { \
.mutex = __MUTEX_INITIALIZER(_name.mutex), \
diff --git a/kernel/bpf/dispatcher.c b/kernel/bpf/dispatcher.c
index 04f0a045dcaa..e14a68e9a74f 100644
--- a/kernel/bpf/dispatcher.c
+++ b/kernel/bpf/dispatcher.c
@@ -91,7 +91,7 @@ int __weak arch_prepare_bpf_dispatcher(void *image, void *buf, s64 *funcs, int n
return -ENOTSUPP;
}
-int __weak __init bpf_arch_init_dispatcher_early(void *ip)
+int __weak __init_or_module bpf_arch_init_dispatcher_early(void *ip)
{
return -ENOTSUPP;
} |
Patch submitted: https://lore.kernel.org/[email protected]/ |
After commit dbe69b2 ("bpf: Fix dispatcher patchable function entry to 5 bytes nop"), building kernel/bpf/dispatcher.c in certain configurations with LLVM's integrated assembler results in a known recordmcount bug: Cannot find symbol for section 4: .init.text. kernel/bpf/dispatcher.o: failed This occurs when there are only weak symbols in a particular section in the translation unit; in this case, bpf_arch_init_dispatcher_early() is marked '__weak __init' and it is the only symbol in the .init.text section. recordmcount expects there to be a symbol for a particular section but LLVM's integrated assembler (and GNU as after 2.37) do not generated section symbols. This has been worked around in the kernel before in commit 55d5b7d ("initramfs: fix clang build failure") and commit 6e7b64b ("elfcore: fix building with clang"). Fixing recordmcount has been brought up before but there is no clear solution that does not break ftrace outright. Unfortunately, working around this issue by removing the '__init' from bpf_arch_init_dispatcher_early() is not an option, as the x86 version of bpf_arch_init_dispatcher_early() calls text_poke_early(), which is marked '__init_or_module', meaning that when CONFIG_MODULES is disabled, bpf_arch_init_dispatcher_early() has to be marked '__init' as well to avoid a section mismatch warning from modpost. However, bpf_arch_init_dispatcher_early() can be marked '__init_or_module' as well, which would resolve the recordmcount warning for configurations that support modules (i.e., the vast majority of them) while not introducing any new warnings for all configurations. Do so to clear up the build failure for CONFIG_MODULES=y configurations. Link: ClangBuiltLinux/linux#981 Signed-off-by: Nathan Chancellor <[email protected]>
After commit dbe69b2 ("bpf: Fix dispatcher patchable function entry to 5 bytes nop"), building kernel/bpf/dispatcher.c in certain configurations with LLVM's integrated assembler results in a known recordmcount bug: Cannot find symbol for section 4: .init.text. kernel/bpf/dispatcher.o: failed This occurs when there are only weak symbols in a particular section in the translation unit; in this case, bpf_arch_init_dispatcher_early() is marked '__weak __init' and it is the only symbol in the .init.text section. recordmcount expects there to be a symbol for a particular section but LLVM's integrated assembler (and GNU as after 2.37) do not generated section symbols. This has been worked around in the kernel before in commit 55d5b7d ("initramfs: fix clang build failure") and commit 6e7b64b ("elfcore: fix building with clang"). Fixing recordmcount has been brought up before but there is no clear solution that does not break ftrace outright. Unfortunately, working around this issue by removing the '__init' from bpf_arch_init_dispatcher_early() is not an option, as the x86 version of bpf_arch_init_dispatcher_early() calls text_poke_early(), which is marked '__init_or_module', meaning that when CONFIG_MODULES is disabled, bpf_arch_init_dispatcher_early() has to be marked '__init' as well to avoid a section mismatch warning from modpost. However, bpf_arch_init_dispatcher_early() can be marked '__init_or_module' as well, which would resolve the recordmcount warning for configurations that support modules (i.e., the vast majority of them) while not introducing any new warnings for all configurations. Do so to clear up the build failure for CONFIG_MODULES=y configurations. Link: ClangBuiltLinux/linux#981 Signed-off-by: Nathan Chancellor <[email protected]>
After commit dbe69b2 ("bpf: Fix dispatcher patchable function entry to 5 bytes nop"), building kernel/bpf/dispatcher.c in certain configurations with LLVM's integrated assembler results in a known recordmcount bug: Cannot find symbol for section 4: .init.text. kernel/bpf/dispatcher.o: failed This occurs when there are only weak symbols in a particular section in the translation unit; in this case, bpf_arch_init_dispatcher_early() is marked '__weak __init' and it is the only symbol in the .init.text section. recordmcount expects there to be a symbol for a particular section but LLVM's integrated assembler (and GNU as after 2.37) do not generated section symbols. This has been worked around in the kernel before in commit 55d5b7d ("initramfs: fix clang build failure") and commit 6e7b64b ("elfcore: fix building with clang"). Fixing recordmcount has been brought up before but there is no clear solution that does not break ftrace outright. Unfortunately, working around this issue by removing the '__init' from bpf_arch_init_dispatcher_early() is not an option, as the x86 version of bpf_arch_init_dispatcher_early() calls text_poke_early(), which is marked '__init_or_module', meaning that when CONFIG_MODULES is disabled, bpf_arch_init_dispatcher_early() has to be marked '__init' as well to avoid a section mismatch warning from modpost. However, bpf_arch_init_dispatcher_early() can be marked '__init_or_module' as well, which would resolve the recordmcount warning for configurations that support modules (i.e., the vast majority of them) while not introducing any new warnings for all configurations. Do so to clear up the build failure for CONFIG_MODULES=y configurations. Link: ClangBuiltLinux/linux#981 Signed-off-by: Nathan Chancellor <[email protected]>
After commit dbe69b2 ("bpf: Fix dispatcher patchable function entry to 5 bytes nop"), building kernel/bpf/dispatcher.c in certain configurations with LLVM's integrated assembler results in a known recordmcount bug: Cannot find symbol for section 4: .init.text. kernel/bpf/dispatcher.o: failed This occurs when there are only weak symbols in a particular section in the translation unit; in this case, bpf_arch_init_dispatcher_early() is marked '__weak __init' and it is the only symbol in the .init.text section. recordmcount expects there to be a symbol for a particular section but LLVM's integrated assembler (and GNU as after 2.37) do not generated section symbols. This has been worked around in the kernel before in commit 55d5b7d ("initramfs: fix clang build failure") and commit 6e7b64b ("elfcore: fix building with clang"). Fixing recordmcount has been brought up before but there is no clear solution that does not break ftrace outright. Unfortunately, working around this issue by removing the '__init' from bpf_arch_init_dispatcher_early() is not an option, as the x86 version of bpf_arch_init_dispatcher_early() calls text_poke_early(), which is marked '__init_or_module', meaning that when CONFIG_MODULES is disabled, bpf_arch_init_dispatcher_early() has to be marked '__init' as well to avoid a section mismatch warning from modpost. However, bpf_arch_init_dispatcher_early() can be marked '__init_or_module' as well, which would resolve the recordmcount warning for configurations that support modules (i.e., the vast majority of them) while not introducing any new warnings for all configurations. Do so to clear up the build failure for CONFIG_MODULES=y configurations. Link: ClangBuiltLinux/linux#981 Signed-off-by: Nathan Chancellor <[email protected]>
It sounds like the original patch that caused the recent bpf issue might get reverted in favor of a difference fix: |
After commit dbe69b2 ("bpf: Fix dispatcher patchable function entry to 5 bytes nop"), building kernel/bpf/dispatcher.c in certain configurations with LLVM's integrated assembler results in a known recordmcount bug: Cannot find symbol for section 4: .init.text. kernel/bpf/dispatcher.o: failed This occurs when there are only weak symbols in a particular section in the translation unit; in this case, bpf_arch_init_dispatcher_early() is marked '__weak __init' and it is the only symbol in the .init.text section. recordmcount expects there to be a symbol for a particular section but LLVM's integrated assembler (and GNU as after 2.37) do not generated section symbols. This has been worked around in the kernel before in commit 55d5b7d ("initramfs: fix clang build failure") and commit 6e7b64b ("elfcore: fix building with clang"). Fixing recordmcount has been brought up before but there is no clear solution that does not break ftrace outright. Unfortunately, working around this issue by removing the '__init' from bpf_arch_init_dispatcher_early() is not an option, as the x86 version of bpf_arch_init_dispatcher_early() calls text_poke_early(), which is marked '__init_or_module', meaning that when CONFIG_MODULES is disabled, bpf_arch_init_dispatcher_early() has to be marked '__init' as well to avoid a section mismatch warning from modpost. However, bpf_arch_init_dispatcher_early() can be marked '__init_or_module' as well, which would resolve the recordmcount warning for configurations that support modules (i.e., the vast majority of them) while not introducing any new warnings for all configurations. Do so to clear up the build failure for CONFIG_MODULES=y configurations. Link: ClangBuiltLinux#981 Signed-off-by: Nathan Chancellor <[email protected]>
Sent a fix for another instance of this problem: https://lore.kernel.org/lkml/[email protected]/T/#u |
Using AS=clang to build with integrated-as, on x86_64, when scripts/recordmcount is run on certain objects (for me it happens with init/initramfs.o and kernel/elfcore.o at least) I get the error in the title.
The text was updated successfully, but these errors were encountered: