Commit 132f6f18 authored by Thomas Huth's avatar Thomas Huth Committed by Paolo Bonzini
Browse files

kbuild: fix asm-offset generation to work with clang

KBuild abuses the asm statement to write to a file and
clang chokes about these invalid asm statements. Hack it
even more by fooling this is actual valid asm code.

This is an adaption of the Linux kernel commit cf0c3e68aa81f992b0
which in turn is based on a patch for the U-Boot:
  http://patchwork.ozlabs.org/patch/375026/

Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
Message-Id: <20201001072234.143703-5-thuth@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
Tested-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
parent 56e2294f
#ifndef _KBUILD_H_
#define _KBUILD_H_
#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
#define OFFSET(sym, str, mem) DEFINE(sym, offsetof(struct str, mem))
#define COMMENT(x) asm volatile("\n->#" x)
#define BLANK() asm volatile("\n->" : : )
#define COMMENT(x) asm volatile("\n.ascii \"->#" x "\"")
#define BLANK() asm volatile("\n.ascii \"->\"" : : )
#endif
......@@ -8,10 +8,11 @@
#
define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
/^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:->::; p;}"
s:->::; p;}'
endef
define make_asm_offsets
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment