Commit 450124cc authored by Roman Bolshakov's avatar Roman Bolshakov Committed by Paolo Bonzini
Browse files

x86: Makefile: Allow division on x86_64-elf binutils

For compatibility with other SVR4 assemblers, '/' starts a comment on
*-elf binutils target and thus division operator is not allowed [1][2].
That breaks cstart64.S build:

  x86/cstart64.S: Assembler messages:
  x86/cstart64.S:294: Error: unbalanced parenthesis in operand 1.

configure should detect if --divide needs to be passed to assembler by
compiling a small snippet where division is used inside parentheses.

1. https://sourceware.org/binutils/docs/as/i386_002dChars.html
2. https://sourceware.org/binutils/docs/as/i386_002dOptions.html#index-_002d_002ddivide-option_002c-i386



Cc: Cameron Esfahani <dirty@apple.com>
Signed-off-by: default avatarRoman Bolshakov <r.bolshakov@yadro.com>
Message-Id: <20200901085056.33391-2-r.bolshakov@yadro.com>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent f441716d
......@@ -15,6 +15,7 @@ endian=""
pretty_print_stacks=yes
environ_default=yes
u32_long=
wa_divide=
vmm="qemu"
errata_force=0
erratatxt="$srcdir/errata.txt"
......@@ -156,6 +157,16 @@ EOF
u32_long=$("$cross_prefix$cc" -E lib-test.c | grep -v '^#' | grep -q long && echo yes)
rm -f lib-test.c
# check if slash can be used for division
if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
cat << EOF > lib-test.S
foo:
movl (8 / 2), %eax
EOF
wa_divide=$("$cross_prefix$cc" -c lib-test.S >/dev/null 2>&1 || echo yes)
rm -f lib-test.{o,S}
fi
# Are we in a separate build tree? If so, link the Makefile
# and shared stuff so that 'make' and run_tests.sh work.
if test ! -e Makefile; then
......@@ -205,6 +216,7 @@ PRETTY_PRINT_STACKS=$pretty_print_stacks
ENVIRON_DEFAULT=$environ_default
ERRATATXT=$erratatxt
U32_LONG_FMT=$u32_long
WA_DIVIDE=$wa_divide
EOF
cat <<EOF > lib/config.h
......
......@@ -29,6 +29,9 @@ $(libcflat): LDFLAGS += -nostdlib
$(libcflat): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I lib
COMMON_CFLAGS += -m$(bits)
ifneq ($(WA_DIVIDE),)
COMMON_CFLAGS += -Wa,--divide
endif
COMMON_CFLAGS += -O1
# stack.o relies on frame pointers.
......
Supports Markdown
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