Skip to contentSkip to conversation

modpost.c: Add .text.unlikely to TEXT_SECTIONS

PATCH In review Tom Rini 2 participants 7 messages Apr 24, 2013 – May 6, 2013 Kbuild

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 modpost.c: Add .text.unlikely to TEXT_SECTIONS

Recent gcc's may place functions into the .text.unlikely section and we need to check this section as well for section mismatches now otherwise we may have false negatives for this test.

---
 scripts/mod/modpost.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
index ff36c50..13ff12f 100644
@@ -880,7 +880,7 @@ static void check_section(const char *modname, struct elf_info *elf,
 #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
 
 #define DATA_SECTIONS ".data$", ".data.rel$"
-#define TEXT_SECTIONS ".text$"
+#define TEXT_SECTIONS ".text$", ".text.unlikely$"
 
 #define INIT_SECTIONS      ".init.*"
 #define CPU_INIT_SECTIONS  ".cpuinit.*"
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 3 lines · Tom Rini

Recent gcc's may place functions into the .text.unlikely section and we need to check this section as well for section mismatches now otherwise we may have false negatives for this test.

Hmm, I don't think it's all that recent, is it? I can find it back to gcc 4.0.4:

`-freorder-functions'
Reorder functions in the object file in order to improve code locality. This is implemented by using special subsections .text.hot' for most frequently executed functions and .text.unlikely' for unlikely executed functions. Reordering is done by the linker so object file format must support named sections and linker must place them in a reasonable way.

Also profile feedback must be available in to make this option effective. See `-fprofile-arcs' for details.

Enabled at levels -O2', -O3', `-Os'.

The comment is the same in in gcc 4.7.

So is your real issue that this section is generated with -fprofile-arcs, or has something changed with gcc 4.8, or...?

Thanks,
Rusty.

Quoted 24 lines
---
 scripts/mod/modpost.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
index ff36c50..13ff12f 100644
@@ -880,7 +880,7 @@ static void check_section(const char *modname, struct elf_info *elf,
 #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
 
 #define DATA_SECTIONS ".data$", ".data.rel$"
-#define TEXT_SECTIONS ".text$"
+#define TEXT_SECTIONS ".text$", ".text.unlikely$"
 
 #define INIT_SECTIONS      ".init.*"
 #define CPU_INIT_SECTIONS  ".cpuinit.*"
Signature · 1 line
1.7.9.5
author
#2 lore raw
Quoted 20 lines · Rusty Russell
Quoted 3 lines · Tom Rini

Recent gcc's may place functions into the .text.unlikely section and we need to check this section as well for section mismatches now otherwise we may have false negatives for this test.

Hmm, I don't think it's all that recent, is it? I can find it back to gcc 4.0.4:

`-freorder-functions'
Reorder functions in the object file in order to improve code locality. This is implemented by using special subsections .text.hot' for most frequently executed functions and .text.unlikely' for unlikely executed functions. Reordering is done by the linker so object file format must support named sections and linker must place them in a reasonable way.

Also profile feedback must be available in to make this option effective. See `-fprofile-arcs' for details.

Quoted 6 lines

Enabled at levels -O2', -O3', `-Os'.

The comment is the same in in gcc 4.7.

So is your real issue that this section is generated with -fprofile-arcs, or has something changed with gcc 4.8, or...?

I've started seeing this with Linaro based 4.7 toolchains. I can go back through their releases and see when it starts showing up there if it helps. I didn't add .text.hot as I didn't have that section at all, fwiw.

Signature · 1 line
Tom
#3 lore raw
Quoted 25 lines · Tom Rini
Quoted 24 lines · Rusty Russell
Quoted 3 lines · Tom Rini

Recent gcc's may place functions into the .text.unlikely section and we need to check this section as well for section mismatches now otherwise we may have false negatives for this test.

Hmm, I don't think it's all that recent, is it? I can find it back to gcc 4.0.4:

`-freorder-functions'
Reorder functions in the object file in order to improve code locality. This is implemented by using special subsections .text.hot' for most frequently executed functions and .text.unlikely' for unlikely executed functions. Reordering is done by the linker so object file format must support named sections and linker must place them in a reasonable way.

Also profile feedback must be available in to make this option effective. See `-fprofile-arcs' for details.

Enabled at levels -O2', -O3', `-Os'.

The comment is the same in in gcc 4.7.

Quoted 7 lines
Quoted 2 lines

So is your real issue that this section is generated with -fprofile-arcs, or has something changed with gcc 4.8, or...?

I've started seeing this with Linaro based 4.7 toolchains. I can go back through their releases and see when it starts showing up there if it helps. I didn't add .text.hot as I didn't have that section at all, fwiw.

Weird, did you turn on CONFIG_GCOV_KERNEL? AFAICT you shouldn't see this section without that.

Thanks,
Rusty.

author
#4 lore raw
Quoted 29 lines · Rusty Russell
Quoted 28 lines · Tom Rini
Quoted 26 lines · Rusty Russell
Quoted 3 lines · Tom Rini

Recent gcc's may place functions into the .text.unlikely section and we need to check this section as well for section mismatches now otherwise we may have false negatives for this test.

Hmm, I don't think it's all that recent, is it? I can find it back to gcc 4.0.4:

`-freorder-functions'
Reorder functions in the object file in order to improve code locality. This is implemented by using special subsections .text.hot' for most frequently executed functions and .text.unlikely' for unlikely executed functions. Reordering is done by the linker so object file format must support named sections and linker must place them in a reasonable way.

Also profile feedback must be available in to make this option effective. See `-fprofile-arcs' for details.

Enabled at levels -O2', -O3', `-Os'.

The comment is the same in in gcc 4.7.

So is your real issue that this section is generated with -fprofile-arcs, or has something changed with gcc 4.8, or...?

Quoted 7 lines
Quoted 4 lines

I've started seeing this with Linaro based 4.7 toolchains. I can go back through their releases and see when it starts showing up there if it helps. I didn't add .text.hot as I didn't have that section at all, fwiw.

Weird, did you turn on CONFIG_GCOV_KERNEL? AFAICT you shouldn't see this section without that.

Nope, CONFIG_GCOV_KERNEL is off. Must be related to whatever flags the Linaro folks set as default on -O2 (at least in their 2013.03 release), after reading over one of the .o.cmd files in the build.

Do you want me to re-word the commit message a bit or ? Thanks!

Signature · 1 line
Tom
author
#5 lore raw
Quoted 35 lines · Tom Rini
Quoted 34 lines · Rusty Russell
Quoted 32 lines · Tom Rini
Quoted 20 lines · Rusty Russell
Quoted 3 lines · Tom Rini

Recent gcc's may place functions into the .text.unlikely section and we need to check this section as well for section mismatches now otherwise we may have false negatives for this test.

Hmm, I don't think it's all that recent, is it? I can find it back to gcc 4.0.4:

`-freorder-functions'
Reorder functions in the object file in order to improve code locality. This is implemented by using special subsections .text.hot' for most frequently executed functions and .text.unlikely' for unlikely executed functions. Reordering is done by the linker so object file format must support named sections and linker must place them in a reasonable way.

Also profile feedback must be available in to make this option effective. See `-fprofile-arcs' for details.

Quoted 6 lines

Enabled at levels -O2', -O3', `-Os'.

The comment is the same in in gcc 4.7.

So is your real issue that this section is generated with -fprofile-arcs, or has something changed with gcc 4.8, or...?

I've started seeing this with Linaro based 4.7 toolchains. I can go back through their releases and see when it starts showing up there if it helps. I didn't add .text.hot as I didn't have that section at all, fwiw.

Quoted 8 lines
Quoted 2 lines

Weird, did you turn on CONFIG_GCOV_KERNEL? AFAICT you shouldn't see this section without that.

Nope, CONFIG_GCOV_KERNEL is off. Must be related to whatever flags the Linaro folks set as default on -O2 (at least in their 2013.03 release), after reading over one of the .o.cmd files in the build.

Do you want me to re-word the commit message a bit or ? Thanks!

I poked around, and every Linaro binary I can grab (2012.01 and gcc 4.6 to 2013.04 and gcc 4.8) has this behaviour.

Signature · 1 line
Tom
#6 lore raw
Quoted 39 lines · Tom Rini
Quoted 38 lines · Tom Rini
Quoted 36 lines · Rusty Russell
Quoted 25 lines · Tom Rini
Quoted 24 lines · Rusty Russell
Quoted 3 lines · Tom Rini

Recent gcc's may place functions into the .text.unlikely section and we need to check this section as well for section mismatches now otherwise we may have false negatives for this test.

Hmm, I don't think it's all that recent, is it? I can find it back to gcc 4.0.4:

`-freorder-functions'
Reorder functions in the object file in order to improve code locality. This is implemented by using special subsections .text.hot' for most frequently executed functions and .text.unlikely' for unlikely executed functions. Reordering is done by the linker so object file format must support named sections and linker must place them in a reasonable way.

Also profile feedback must be available in to make this option effective. See `-fprofile-arcs' for details.

Enabled at levels -O2', -O3', `-Os'.

The comment is the same in in gcc 4.7.

Quoted 7 lines
Quoted 2 lines

So is your real issue that this section is generated with -fprofile-arcs, or has something changed with gcc 4.8, or...?

I've started seeing this with Linaro based 4.7 toolchains. I can go back through their releases and see when it starts showing up there if it helps. I didn't add .text.hot as I didn't have that section at all, fwiw.

Weird, did you turn on CONFIG_GCOV_KERNEL? AFAICT you shouldn't see this section without that.

Quoted 8 lines
Quoted 5 lines

Nope, CONFIG_GCOV_KERNEL is off. Must be related to whatever flags the Linaro folks set as default on -O2 (at least in their 2013.03 release), after reading over one of the .o.cmd files in the build.

Do you want me to re-word the commit message a bit or ? Thanks!

I poked around, and every Linaro binary I can grab (2012.01 and gcc 4.6 to 2013.04 and gcc 4.8) has this behaviour.

I should have checked earlier; happens here too. Looks like a documentation bug. I've filed it here:

        http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57182

So I reworded it slightly, and applied.

Thanks!
Rusty.

From: Tom Rini <[email protected]>
Subject: modpost.c: Add .text.unlikely to TEXT_SECTIONS

gcc's places cold functions into the .text.unlikely section and we need to check this section as well for section mismatches otherwise we may have false negatives for this test.

---
 scripts/mod/modpost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
index a4be8e1..3d155dd 100644
@@ -884,7 +884,7 @@ static void check_section(const char *modname, struct elf_info *elf,
 #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
 
 #define DATA_SECTIONS ".data$", ".data.rel$"
-#define TEXT_SECTIONS ".text$"
+#define TEXT_SECTIONS ".text$", ".text.unlikely$"
 
 #define INIT_SECTIONS      ".init.*"
 #define CPU_INIT_SECTIONS  ".cpuinit.*"