modpost: Skip .llvm.call-graph-profile section check
PATCH 1/1 modpost: Skip .llvm.call-graph-profile section check
.llvm.call-graph-profile section is added when the kernel is built with profiles (e.g. -fprofile-sample-use=<llvm.profile>). The section holds metadata for symbols beloning to other sections and hence doesn't need modpost checks.
This change fixes the kernel build with sample profiles which fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
--- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+)
scripts/mod/modpost.c +1 -0
@@ -761,6 +761,7 @@ static const char *const section_white_list[] =".fmt_slot*" ,/* EZchip */ ".gnu.lto*" ,".discard.*" , +".llvm.call-graph-profile" ,/* call graph */ NULL };
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Quoted 3 lines · Denis Nikitin
.llvm.call-graph-profile section is added when the kernel is built with profiles (e.g. -fprofile-sample-use=<llvm.profile>).
Right. .llvm.call-graph-profile may also be added when the kernel is built with clang -fprofile-use= (though instrumentation-based PGO support is not upstreamed yet).
Quoted 3 lines
The section holds
metadata for symbols beloning to other sections and hence doesn't need modpost checks.
Typo: belonging.
.llvm.call-graph-profile contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
Quoted 22 lines
This change fixes the kernel build with sample profiles which fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"Signed-off-by Denis Nikitin <[email protected]>--- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+)scripts/mod/modpost.c +1
-1@@ -761,6 +761,7 @@ static const char *const section_white_list[] =".fmt_slot*" ,/* EZchip */ ".gnu.lto*" ,".discard.*" , +".llvm.call-graph-profile" ,/* call graph */ NULL }; --
Quoted 3 lines
2.42.0.rc1.204.g551eb34607-goog
Otherwise the change looks good to me.
Signature · 1 line
宋方睿
Thanks for the prompt review!
Quoted 9 lines · Fangrui Song
Quoted 3 lines · Denis Nikitin
.llvm.call-graph-profile section is added when the kernel is built with profiles (e.g. -fprofile-sample-use=<llvm.profile>).
Right. .llvm.call-graph-profile may also be added when the kernel is built with clang -fprofile-use= (though instrumentation-based PGO support is not upstreamed yet).
OK, I will add -fprofile-use.
Quoted 9 lines
Quoted 3 lines
The section holds
metadata for symbols beloning to other sections and hence doesn't need modpost checks.Typo: belonging.
.llvm.call-graph-profile contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
Ack.
Thanks,
Denis
Quoted 11 lines · Denis Nikitin
.llvm.call-graph-profile section is added when the kernel is built with profiles (e.g. -fprofile-sample-use=<llvm.profile>). The section holds metadata for symbols beloning to other sections and hence doesn't need modpost checks.
This change fixes the kernel build with sample profiles which fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"Signed-off-by Denis Nikitin <[email protected]>
Thanks for the patch. If you send a v2 with Fangrui's suggested changes+additions, feel free to carry forward my reviewed by tag.
Quoted 19 lines
--- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+)scripts/mod/modpost.c +1
-1@@ -761,6 +761,7 @@ static const char *const section_white_list[] =".fmt_slot*" ,/* EZchip */ ".gnu.lto*" ,".discard.*" , +".llvm.call-graph-profile" ,/* call graph */ NULL }; --2.42.0.rc1.204.g551eb34607-goog
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 12 lines · Nick Desaulniers
Quoted 10 lines · Denis Nikitin
.llvm.call-graph-profile section is added when the kernel is built with profiles (e.g. -fprofile-sample-use=<llvm.profile>). The section holds metadata for symbols beloning to other sections and hence doesn't need modpost checks.
This change fixes the kernel build with sample profiles which fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
Quoted 7 lines
Quoted 1 line
Signed-off-by Denis Nikitin <[email protected]>Thanks for the patch. If you send a v2 with Fangrui's suggested changes+additions, feel free to carry forward my reviewed by tag.
Reviewed-by Nick Desaulniers <[email protected]>
Thanks! Will do shortly.
- Denis
PATCH v2 1/1 modpost: Skip .llvm.call-graph-profile section check
In reply to Denis Nikitin.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=).
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
--- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+)
scripts/mod/modpost.c +1 -0
@@ -761,6 +761,7 @@ static const char *const section_white_list[] =".fmt_slot*" ,/* EZchip */ ".gnu.lto*" ,".discard.*" , +".llvm.call-graph-profile" ,/* call graph */ NULL };
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Quoted 8 lines · Denis Nikitin
.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=).
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
Quoted 7 lines
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
Signed-off-by Denis Nikitin <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>
Thanks. The new commit message looks good to me.
Quoted 19 lines
--- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+)scripts/mod/modpost.c +1
-1@@ -761,6 +761,7 @@ static const char *const section_white_list[] =".fmt_slot*" ,/* EZchip */ ".gnu.lto*" ,".discard.*" , +".llvm.call-graph-profile" ,/* call graph */ NULL }; --2.42.0.rc1.204.g551eb34607-goog
Signature · 1 line
宋方睿
Quoted 6 lines · Fangrui Song
Quoted 4 lines · Denis Nikitin
.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=).
Quoted 8 lines
Quoted 8 lines
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
Curious.
This message is only displayed for REL.
(Please not it is located in section_rel() function)
I think modern architectures use RELA instead of REL. Which architecture are we talking about?
What does the output of this command look like?
$ llvm-readelf -S vmlinux.o | grep .llvm.call-graph-profile
Is it REL?
Quoted 31 lines
Quoted 3 lines
Signed-off-by Denis Nikitin <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>Thanks. The new commit message looks good to me.
Reviewed-by Fangrui Song <[email protected]>Quoted 17 lines
--- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+)scripts/mod/modpost.c +1
-1@@ -761,6 +761,7 @@ static const char *const section_white_list[] =".fmt_slot*" ,/* EZchip */ ".gnu.lto*" ,".discard.*" , +".llvm.call-graph-profile" ,/* call graph */ NULL }; --Quoted 2 lines
2.42.0.rc1.204.g551eb34607-goog
--
宋方睿
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 20 lines · Masahiro Yamada
Quoted 6 lines · Fangrui Song
Quoted 4 lines · Denis Nikitin
.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=).
Quoted 8 lines
Quoted 8 lines
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
Curious.
Quoted 7 lines
This message is only displayed for REL.
(Please not it is located in
section_rel()function)I think modern architectures use RELA instead of REL. Which architecture are we talking about?
Aarch64. There was also a report on x86-64 but the error message could be different there.
Quoted 9 lines
What does the output of this command look like?
$ llvm-readelf -S vmlinux.o | grep .llvm.call-graph-profileIs it REL?
[119] .llvm.call-graph-profile LLVM_CALL_GRAPH_PROFILE 00000000000000001c74a458 0104c8 08 E 0 0 1
[120] .rel.llvm.call-graph-profile REL 0000000000000000 1c75a920 041320 10
I 26090 119 8
Thanks,
Denis
Quoted 24 lines · Denis Nikitin
Quoted 22 lines · Masahiro Yamada
Quoted 6 lines · Fangrui Song
Quoted 4 lines · Denis Nikitin
.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=).
Quoted 8 lines
Quoted 8 lines
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
Curious.
This message is only displayed for REL.
Quoted 8 lines
Quoted 5 lines
(Please not it is located in
section_rel()function)I think modern architectures use RELA instead of REL. Which architecture are we talking about?
Aarch64. There was also a report on x86-64 but the error message could be different there.
Regarding REL:
The original format of .llvm.call-graph-profile (SHT_LLVM_CALL_GRAPH_PROFILE=0x6fff4c02) used symbol indices without relocations and could be corrupted by symbol table change.
https://github.com/llvm/llvm-project/commit/a224c5199b327ed0efcdcd87b6dbf950cf4d9ee1
(2021) changed the format to represent call edge information with R_*_NONE and changed SHT_LLVM_CALL_GRAPH_PROFILE to 0x6fff4c09.
We don't use the addend field of R_*_NONE relocations, so I proposed
that we use REL for all targets.
My https://github.com/llvm/llvm-project/commit/ca3bdb57fa1ac98b711a735de048c12b5fdd8086
selected REL for .llvm.call-graph-profile
aaelf64 says:
Quoted 1 line
A binary file may use ``REL`` or ``RELA`` relocations or a mixture of the two (but multiple relocations of the same place must use only one type).
Other psABI documents may be more vague on how REL is used, but as long as the tool that needs to process it (currently just lld and readelf like tools) supports it, it's fine.
binutils seems to support REL for all ELF targets, even if its objcopy/strip may unintentionally convert REL to RELA. lld can consume RELA SHT_LLVM_CALL_GRAPH_PROFILE.
Quoted 17 lines
Quoted 9 lines
What does the output of this command look like?
$ llvm-readelf -S vmlinux.o | grep .llvm.call-graph-profileIs it REL?
[119] .llvm.call-graph-profile
LLVM_CALL_GRAPH_PROFILE00000000000000001c74a4580104c8 08 E 0 0 1
[120] .rel.llvm.call-graph-profile REL 00000000000000001c75a920041320 10
I 26090 119 8Thanks,
Denis
Signature · 1 line
宋方睿
Quoted 51 lines · Fangrui Song
Quoted 24 lines · Denis Nikitin
Quoted 22 lines · Masahiro Yamada
Quoted 6 lines · Fangrui Song
Quoted 4 lines · Denis Nikitin
.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=).
Quoted 8 lines
Quoted 8 lines
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
Curious.
This message is only displayed for REL.
Quoted 8 lines
Quoted 5 lines
(Please not it is located in
section_rel()function)I think modern architectures use RELA instead of REL. Which architecture are we talking about?
Aarch64. There was also a report on x86-64 but the error message could be different there.
Regarding REL:
The original format of .llvm.call-graph-profile (SHT_LLVM_CALL_GRAPH_PROFILE=0x6fff4c02) used symbol indices without relocations and could be corrupted by symbol table change.
https://github.com/llvm/llvm-project/commit/a224c5199b327ed0efcdcd87b6dbf950cf4d9ee1
(2021) changed the format to represent call edge information with R_*_NONE and changedSHT_LLVM_CALL_GRAPH_PROFILEto0x6fff4c09.We don't use the addend field of R_*_NONE relocations, so I proposed
that we use REL for all targets.
My https://github.com/llvm/llvm-project/commit/ca3bdb57fa1ac98b711a735de048c12b5fdd8086
selected REL for .llvm.call-graph-profileaaelf64 says:
Quoted 26 lines
Quoted 1 line
A binary file may use ``REL`` or ``RELA`` relocations or a mixture of the two (but multiple relocations of the same place must use only one type).
Other psABI documents may be more vague on how REL is used, but as long as the tool that needs to process it (currently just lld and readelf like tools) supports it, it's fine.
binutils seems to support REL for all ELF targets, even if its objcopy/strip may unintentionally convert REL to RELA. lld can consume RELASHT_LLVM_CALL_GRAPH_PROFILE.Quoted 17 lines
Quoted 9 lines
What does the output of this command look like?
$ llvm-readelf -S vmlinux.o | grep .llvm.call-graph-profileIs it REL?
[119] .llvm.call-graph-profile
LLVM_CALL_GRAPH_PROFILE00000000000000001c74a4580104c8 08 E 0 0 1
[120] .rel.llvm.call-graph-profile REL 00000000000000001c75a920041320 10
I 26090 119 8Thanks,
Denis
Thanks, Fangrui.
I'd like the commit log to record the use of REL for .llvm.call-graph-profile is intentional.
Denis, could you add some more comments?
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 10 lines
Thanks, Fangrui.
I'd like the commit log to record the use of REL for .llvm.call-graph-profile is intentional.
Denis, could you add some more comments?
Sure, I will send a new version.
Thanks,
Denis
Quoted 5 lines
--
Best Regards
Masahiro Yamada
Quoted 40 lines · Denis Nikitin
Quoted 20 lines · Masahiro Yamada
Quoted 6 lines · Fangrui Song
Quoted 4 lines · Denis Nikitin
.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=).
Quoted 8 lines
Quoted 8 lines
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
Curious.
Quoted 7 lines
This message is only displayed for REL.
(Please not it is located in
section_rel()function)I think modern architectures use RELA instead of REL. Which architecture are we talking about?
Aarch64. There was also a report on x86-64 but the error message could be different there.
Quoted 7 lines
What does the output of this command look like?
$ llvm-readelf -S vmlinux.o | grep .llvm.call-graph-profile
Quoted 7 lines
Quoted 2 lines
Is it REL?
[119] .llvm.call-graph-profile
LLVM_CALL_GRAPH_PROFILE00000000000000001c74a4580104c8 08 E 0 0 1
[120] .rel.llvm.call-graph-profile REL 00000000000000001c75a920041320 10
I 26090 119 8
Fangrui,
Aarch64 uses RELA for other sections, but REL for this one.
I'd like to confirm if this is an expectation, not a toolchain bug.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 51 lines · Masahiro Yamada
Quoted 40 lines · Denis Nikitin
Quoted 20 lines · Masahiro Yamada
Quoted 6 lines · Fangrui Song
Quoted 4 lines · Denis Nikitin
.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=).
Quoted 8 lines
Quoted 8 lines
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
Curious.
Quoted 7 lines
This message is only displayed for REL.
(Please not it is located in
section_rel()function)I think modern architectures use RELA instead of REL. Which architecture are we talking about?
Aarch64. There was also a report on x86-64 but the error message could be different there.
Quoted 7 lines
What does the output of this command look like?
$ llvm-readelf -S vmlinux.o | grep .llvm.call-graph-profileQuoted 7 lines
Quoted 2 lines
Is it REL?
[119] .llvm.call-graph-profile
LLVM_CALL_GRAPH_PROFILE00000000000000001c74a4580104c8 08 E 0 0 1
[120] .rel.llvm.call-graph-profile REL 00000000000000001c75a920041320 10
I 26090 119 8
Quoted 5 lines
Fangrui,
Aarch64 uses RELA for other sections, but REL for this one.
I'd like to confirm if this is an expectation, not a toolchain bug.
Hi Masahiro,
Yes, using REL is intentional. It makes the relocations of .llvm.call-graph-profile smaller.
The format encodes the (from,to,count) information with
* the section content holds 'count'
* two R_*_NONE relocations hold 'from' and 'to'. The addend field is unused, therefore REL is better.
Signature · 1 line
宋方睿
PATCH v3 1/1 modpost: Skip .llvm.call-graph-profile section check
In reply to Denis Nikitin.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=). Note that .llvm.call-graph-profile intentionally uses REL relocations to decrease the object size, for more details see
https://reviews.llvm.org/D104080.
The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
"FATAL: modpost: Please add code to calculate addend for this architecture"
--- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+)
scripts/mod/modpost.c +1 -0
@@ -761,6 +761,7 @@ static const char *const section_white_list[] =".fmt_slot*" ,/* EZchip */ ".gnu.lto*" ,".discard.*" , +".llvm.call-graph-profile" ,/* call graph */ NULL };
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Quoted 14 lines · Denis Nikitin
.llvm.call-graph-profile section is added by clang when the kernel is built with profiles (e.g. -fprofile-sample-use= or -fprofile-use=). Note that .llvm.call-graph-profile intentionally uses REL relocations to decrease the object size, for more details see
https://reviews.llvm.org/D104080.The section contains edge information derived from text sections, so .llvm.call-graph-profile itself doesn't need more analysis as the text sections have been analyzed.
This change fixes the kernel build with clang and a sample profile which currently fails with:
Quoted 6 lines
"FATAL: modpost: Please add code to calculate addend for this architecture"
Signed-off-by Denis Nikitin <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>Reviewed-by Fangrui Song <[email protected]>---
Applied to linux-kbuild.
Thanks.
Quoted 18 lines
scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+)scripts/mod/modpost.c +1
-1@@ -761,6 +761,7 @@ static const char *const section_white_list[] =".fmt_slot*" ,/* EZchip */ ".gnu.lto*" ,".discard.*" , +".llvm.call-graph-profile" ,/* call graph */ NULL }; --2.42.0.rc1.204.g551eb34607-goog
Signature · 2 lines
Best Regards Masahiro Yamada