linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* objtool: Use value of intended enum to compile with clang
@ 2017-12-10 18:34 Lukas Bulwahn
  2017-12-10 18:35 ` [PATCH] " Lukas Bulwahn
  0 siblings, 1 reply; 3+ messages in thread
From: Lukas Bulwahn @ 2017-12-10 18:34 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: sil2review, Ingo Molnar, Lukas Bulwahn, Jiri Slaby, linux-kernel

Hi,

Please include this patch in tools/objtool to properly compile with clang-5.0.

I successfully compiled this patch (make defconfig && make) on top of tag
next-20171208 from linux-next with clang-5.0.0 and gcc (Debian 7.2.0-16) 7.2.0,
but I did not test anything further than that.

Exact compiler version of clang-5.0.0 is:

  clang version 5.0.0-+rc2-1 (tags/RELEASE_500/rc2)
  Target: x86_64-pc-linux-gnu
  Thread model: posix
  InstalledDir: /usr/bin

This is my first kernel contribution, so please apologize any kernel newbie
mistakes.

Lukas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] objtool: Use value of intended enum to compile with clang
  2017-12-10 18:34 objtool: Use value of intended enum to compile with clang Lukas Bulwahn
@ 2017-12-10 18:35 ` Lukas Bulwahn
  2017-12-10 20:19   ` [SIL2review] " Nicholas Mc Guire
  0 siblings, 1 reply; 3+ messages in thread
From: Lukas Bulwahn @ 2017-12-10 18:35 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: sil2review, Lukas Bulwahn, Ingo Molnar, Jiri Slaby, linux-kernel

Just use the right value and avoid an implicit conversion between the two
enumeration types that just happened to work in this case. It seems that
this must have just been overlooked in the new implementation of objtool
in commit baa41469a7b9 ("objtool: Implement stack validation 2.0").

I found this when compiling the kernel with clang-5.0, i.e., executing

  make HOSTCC=clang-5.0 CC=clang-5.0 defconfig && \
  make HOSTCC=clang-5.0 CC=clang-5.0

fails with:

```
arch/x86/decode.c:141:20: error: implicit conversion from enumeration type 'enum op_src_type' to different enumeration type 'enum op_dest_type' [-Werror,-Wenum-conversion]
                        op->dest.type = OP_SRC_REG;
                                      ~ ^~~~~~~~~~
1 error generated.
```

Fixes: baa41469a7b9 ("objtool: Implement stack validation 2.0")
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
---
 tools/objtool/arch/x86/decode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 8acfc47..540a209 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -138,7 +138,7 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
 			*type = INSN_STACK;
 			op->src.type = OP_SRC_ADD;
 			op->src.reg = op_to_cfi_reg[modrm_reg][rex_r];
-			op->dest.type = OP_SRC_REG;
+			op->dest.type = OP_DEST_REG;
 			op->dest.reg = CFI_SP;
 		}
 		break;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [SIL2review] [PATCH] objtool: Use value of intended enum to compile with clang
  2017-12-10 18:35 ` [PATCH] " Lukas Bulwahn
@ 2017-12-10 20:19   ` Nicholas Mc Guire
  0 siblings, 0 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2017-12-10 20:19 UTC (permalink / raw)
  To: Lukas Bulwahn
  Cc: Josh Poimboeuf, sil2review, Jiri Slaby, Ingo Molnar, linux-kernel

On Sun, Dec 10, 2017 at 07:35:00PM +0100, Lukas Bulwahn wrote:
> Just use the right value and avoid an implicit conversion between the two
> enumeration types that just happened to work in this case. It seems that
> this must have just been overlooked in the new implementation of objtool
> in commit baa41469a7b9 ("objtool: Implement stack validation 2.0").
> 
> I found this when compiling the kernel with clang-5.0, i.e., executing
> 
>   make HOSTCC=clang-5.0 CC=clang-5.0 defconfig && \
>   make HOSTCC=clang-5.0 CC=clang-5.0
> 
> fails with:
> 
> ```
> arch/x86/decode.c:141:20: error: implicit conversion from enumeration type 'enum op_src_type' to different enumeration type 'enum op_dest_type' [-Werror,-Wenum-conversion]
>                         op->dest.type = OP_SRC_REG;
>                                       ~ ^~~~~~~~~~
> 1 error generated.
> ```

given the declaration in tools/objtool/arch.h
enum op_dest_type {
        OP_DEST_REG,
        ...

enum op_src_type {
        OP_SRC_REG,
        ...

the change seems correct and it is clear why it worked with the wrong type

> 
> Fixes: baa41469a7b9 ("objtool: Implement stack validation 2.0")
> Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Reviewed-by: Nicholas Mc Guire <der.herr@hofr.at>

> ---
>  tools/objtool/arch/x86/decode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
> index 8acfc47..540a209 100644
> --- a/tools/objtool/arch/x86/decode.c
> +++ b/tools/objtool/arch/x86/decode.c
> @@ -138,7 +138,7 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
>  			*type = INSN_STACK;
>  			op->src.type = OP_SRC_ADD;
>  			op->src.reg = op_to_cfi_reg[modrm_reg][rex_r];
> -			op->dest.type = OP_SRC_REG;
> +			op->dest.type = OP_DEST_REG;
>  			op->dest.reg = CFI_SP;
>  		}
>  		break;
> -- 
> 2.7.4
> 
> _______________________________________________
> SIL2review mailing list
> SIL2review@lists.osadl.org
> https://lists.osadl.org/mailman/listinfo/sil2review

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-10 20:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-10 18:34 objtool: Use value of intended enum to compile with clang Lukas Bulwahn
2017-12-10 18:35 ` [PATCH] " Lukas Bulwahn
2017-12-10 20:19   ` [SIL2review] " Nicholas Mc Guire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).