Skip to contentSkip to conversation

Problems compiling with KCFLAGS="-frecord-gcc-switches"

DISCUSSION Guenter Roeck 2 participants 9 messages Sep 29, 2017 – Oct 3, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Any idea what might cause this problem ?

Thanks,
Guenter

#1 lore raw
Quoted 24 lines · Guenter Roeck

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Quoted 2 lines

Any idea what might cause this problem ?

Here is another interesting problem, seen when building arm64 allmodconfig -CONFIG_CPU_BIG_ENDIAN +CONFIG_EFI.

kallsyms failure:

	relative symbol value 0xffffff9008073000 out of range in relative mode

This is due to symbols such as

000000000000000e n __efistub_$d

in the symbol table. Those are not filtered out by kallsyms, resulting in a relative "base" address of 0x0e, and all other symbols are out of range. Those symbols are only generated in efi/libstubs.

Any idea what might be going on there, and how to fix it ? An easy fix would be something like

- else if (stype == 'N')
+ else if (toupper(stype) == 'N')

in kallsyms, but that doesn't seem like a clean solution to me.

Thanks,
Guenter

#4 lore raw
In reply to Guenter Roeck
Quoted 24 lines · Guenter Roeck

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Quoted 1 line

Any idea what might cause this problem ?

I think this is a GCC bug with the -frecord-gcc-switches feature. Due to some ambiguity in some inline asm in emulate.c, it's placing some kernel code in the .GCC.command.line section.

This seems to fix it:

arch/x86/kvm/emulate.c +4 -2
index a36254cbf776..d90cdc77e077 100644
@@ -425,8 +425,10 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
 	#op " %al \n\t" \
 	FOP_RET
 
-asm(".global kvm_fastop_exception \n"
-    "kvm_fastop_exception: xor %esi, %esi; ret");
+asm(".pushsection .fixup, \"ax\"\n"
+    ".global kvm_fastop_exception \n"
+    "kvm_fastop_exception: xor %esi, %esi; ret\n"
+    ".popsection");
 
 FOP_START(setcc)
 FOP_SETCC(seto)
#2 lore raw
In reply to Guenter Roeck
Quoted 48 lines · Guenter Roeck
Quoted 24 lines · Guenter Roeck

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Quoted 2 lines

Any idea what might cause this problem ?

Here is another interesting problem, seen when building arm64 allmodconfig -CONFIG_CPU_BIG_ENDIAN +CONFIG_EFI.

kallsyms failure:

	relative symbol value 0xffffff9008073000 out of range in relative mode

This is due to symbols such as

000000000000000e n __efistub_$d

in the symbol table. Those are not filtered out by kallsyms, resulting in a relative "base" address of 0x0e, and all other symbols are out of range. Those symbols are only generated in efi/libstubs.

Any idea what might be going on there, and how to fix it ? An easy fix would be something like

(quoted diff) +1 -1
-       else if (stype == 'N')
+       else if (toupper(stype) == 'N')
Quoted 1 line

in kallsyms, but that doesn't seem like a clean solution to me.

Not sure... What does 'n' mean? I don't see it in the man page for nm.

Signature · 1 line
Josh
#3 lore raw
Quoted 46 lines · Josh Poimboeuf
Quoted 45 lines · Guenter Roeck
Quoted 24 lines · Guenter Roeck

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Quoted 2 lines

Any idea what might cause this problem ?

Here is another interesting problem, seen when building arm64 allmodconfig -CONFIG_CPU_BIG_ENDIAN +CONFIG_EFI.

kallsyms failure:

	relative symbol value 0xffffff9008073000 out of range in relative mode

This is due to symbols such as

000000000000000e n __efistub_$d

in the symbol table. Those are not filtered out by kallsyms, resulting in a relative "base" address of 0x0e, and all other symbols are out of range. Those symbols are only generated in efi/libstubs.

Any idea what might be going on there, and how to fix it ? An easy fix would be something like

Quoted 7 lines
Quoted 4 lines
(quoted diff) +1 -1
-       else if (stype == 'N')
+       else if (toupper(stype) == 'N')

in kallsyms, but that doesn't seem like a clean solution to me.

Not sure... What does 'n' mean? I don't see it in the man page for nm.

Good question. As far as I can see, gcc uses it to mark symbols associated with -frecord-gcc-switches, presumably in the .GCC.command.line section.

Guenter

author Tested-by
#5 lore raw
In reply to Josh Poimboeuf
Quoted 25 lines · Josh Poimboeuf
Quoted 24 lines · Guenter Roeck

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Quoted 6 lines
Quoted 1 line

Any idea what might cause this problem ?

I think this is a GCC bug with the -frecord-gcc-switches feature. Due to some ambiguity in some inline asm in emulate.c, it's placing some kernel code in the .GCC.command.line section.

Interesting. Makes me wonder if it is doing something similar in the efi code.

Quoted 11 lines

This seems to fix it:

arch/x86/kvm/emulate.c +0 -0
index a36254cbf776..d90cdc77e077 100644
@@ -425,8 +425,10 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
  	#op " %al \n\t" \
  	FOP_RET

arch/x86/kvm/emulate.c static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); · line 434

Quoted 10 lines
arch/x86/kvm/emulate.c +4 -2
 
-asm(".global kvm_fastop_exception \n"
-    "kvm_fastop_exception: xor %esi, %esi; ret");
+asm(".pushsection .fixup, \"ax\"\n"
+    ".global kvm_fastop_exception \n"
+    "kvm_fastop_exception: xor %esi, %esi; ret\n"
+    ".popsection");
 
  FOP_START(setcc)
  FOP_SETCC(seto)

Yes, that fixes the problem for me.

Do you want to send a real patch ? If yes, feel free to add

Thanks,
Guenter

#6 lore raw
In reply to Josh Poimboeuf

Hi Josh,

Quoted 41 lines · Josh Poimboeuf
Quoted 24 lines · Guenter Roeck

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Quoted 1 line

Any idea what might cause this problem ?

I think this is a GCC bug with the -frecord-gcc-switches feature. Due to some ambiguity in some inline asm in emulate.c, it's placing some kernel code in the .GCC.command.line section.

This seems to fix it:

arch/x86/kvm/emulate.c +0 -0
index a36254cbf776..d90cdc77e077 100644
@@ -425,8 +425,10 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
 	#op " %al \n\t" \
 	FOP_RET

arch/x86/kvm/emulate.c static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); · line 434

Quoted 10 lines
arch/x86/kvm/emulate.c +4 -2
 
-asm(".global kvm_fastop_exception \n"
-    "kvm_fastop_exception: xor %esi, %esi; ret");
+asm(".pushsection .fixup, \"ax\"\n"
+    ".global kvm_fastop_exception \n"
+    "kvm_fastop_exception: xor %esi, %esi; ret\n"
+    ".popsection");
 
 FOP_START(setcc)
 FOP_SETCC(seto)

Do you plan to submit a patch for this, or do you want me to do it ?

Thanks,
Guenter

#7 lore raw
Quoted 52 lines · Guenter Roeck

Hi Josh,

Quoted 49 lines · Josh Poimboeuf
Quoted 24 lines · Guenter Roeck

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Quoted 1 line

Any idea what might cause this problem ?

I think this is a GCC bug with the -frecord-gcc-switches feature. Due to some ambiguity in some inline asm in emulate.c, it's placing some kernel code in the .GCC.command.line section.

This seems to fix it:

arch/x86/kvm/emulate.c +4 -2
index a36254cbf776..d90cdc77e077 100644
@@ -425,8 +425,10 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
 	#op " %al \n\t" \
 	FOP_RET
 
-asm(".global kvm_fastop_exception \n"
-    "kvm_fastop_exception: xor %esi, %esi; ret");
+asm(".pushsection .fixup, \"ax\"\n"
+    ".global kvm_fastop_exception \n"
+    "kvm_fastop_exception: xor %esi, %esi; ret\n"
+    ".popsection");
 
Quoted 4 lines

arch/x86/kvm/emulate.c static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); · line 434

Quoted 2 lines
arch/x86/kvm/emulate.c +0 -0
 FOP_START(setcc)
 FOP_SETCC(seto)

Do you plan to submit a patch for this, or do you want me to do it ?

Sorry, I've been juggling a bunch of other bugs. I'll submit it soon.

Signature · 1 line
Josh
#8 lore raw
Quoted 53 lines · Josh Poimboeuf
Quoted 52 lines · Guenter Roeck

Hi Josh,

Quoted 49 lines · Josh Poimboeuf
Quoted 24 lines · Guenter Roeck

Hi Josh,

when trying to compile an image with KCFLAGS="-frecord-gcc-switches", I get the folllowing build warning/error.

make allmodconfig
KCFLAGS="-frecord-gcc-switches" make arch/x86/kvm/emulate.o ./tools/objtool/objtool check --no-unreachable "arch/x86/kvm/emulate.o"

arch/x86/kvm/emulate.o: warning:

	objtool: .GCC.command.line+0x0: special: can't find new instruction

Building a full image aborts with:

WARNING: arch/x86/kvm/kvm.o(__ex_table+0x4c): Section mismatch in reference
from the (unknown reference) (unknown)
to the variable .GCC.command.line:kvm_fastop_exception
FATAL: The relocation at __ex_table+0x4c references
section ".GCC.command.line" which is not executable, IOW
the kernel will fault if it ever tries to
jump to it. Something is seriously wrong
and should be fixed.
make[2]: *** [arch/x86/kvm/kvm.o] Error 1

Quoted 1 line

Any idea what might cause this problem ?

I think this is a GCC bug with the -frecord-gcc-switches feature. Due to some ambiguity in some inline asm in emulate.c, it's placing some kernel code in the .GCC.command.line section.

This seems to fix it:

arch/x86/kvm/emulate.c +4 -2
index a36254cbf776..d90cdc77e077 100644
@@ -425,8 +425,10 @@ static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *));
 	#op " %al \n\t" \
 	FOP_RET
 
-asm(".global kvm_fastop_exception \n"
-    "kvm_fastop_exception: xor %esi, %esi; ret");
+asm(".pushsection .fixup, \"ax\"\n"
+    ".global kvm_fastop_exception \n"
+    "kvm_fastop_exception: xor %esi, %esi; ret\n"
+    ".popsection");
 
Quoted 7 lines
Quoted 4 lines

arch/x86/kvm/emulate.c static int fastop(struct x86_emulate_ctxt *ctxt, void (*fop)(struct fastop *)); · line 434

Quoted 2 lines
arch/x86/kvm/emulate.c +0 -0
 FOP_START(setcc)
 FOP_SETCC(seto)

Do you plan to submit a patch for this, or do you want me to do it ?

Sorry, I've been juggling a bunch of other bugs. I'll submit it soon.

Welcome to the club ...

Thanks!
Guenter