Skip to content

Commit

Permalink
rseq/selftests: x86: Work-around bogus gcc-8 optimisation
Browse files Browse the repository at this point in the history
gcc-8 version 8.1.0, 8.2.0, and 8.3.0 generate broken assembler with asm
goto that have a thread-local storage "m" input operand on both x86-32
and x86-64. For instance:

__thread int var;

static int fct(void)
{
        asm goto (      "jmp %l[testlabel]\n\t"
                        : : [var] "m" (var) : : testlabel);
        return 0;
testlabel:
        return 1;
}

int main()
{
        return fct();
}

% gcc-8 -O2 -o test-asm-goto test-asm-goto.c
/tmp/ccAdHJbe.o: In function `main':
test-asm-goto.c:(.text.startup+0x1): undefined reference to `.L2'
collect2: error: ld returned 1 exit status

% gcc-8 -m32 -O2 -o test-asm-goto test-asm-goto.c
/tmp/ccREsVXA.o: In function `main':
test-asm-goto.c:(.text.startup+0x1): undefined reference to `.L2'
collect2: error: ld returned 1 exit status

Work-around this compiler bug in the rseq-x86.h header by passing the
address of the __rseq_abi TLS as a register operand rather than using
the "m" input operand.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90193
Signed-off-by: Mathieu Desnoyers <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Peter Zijlstra <[email protected]>
CC: Thomas Gleixner <[email protected]>
CC: Joel Fernandes <[email protected]>
CC: Catalin Marinas <[email protected]>
CC: Dave Watson <[email protected]>
CC: Will Deacon <[email protected]>
CC: Shuah Khan <[email protected]>
CC: Andi Kleen <[email protected]>
CC: [email protected]
CC: "H . Peter Anvin" <[email protected]>
CC: Chris Lameter <[email protected]>
CC: Russell King <[email protected]>
CC: Michael Kerrisk <[email protected]>
CC: "Paul E . McKenney" <[email protected]>
CC: Paul Turner <[email protected]>
CC: Boqun Feng <[email protected]>
CC: Josh Triplett <[email protected]>
CC: Steven Rostedt <[email protected]>
CC: Ben Maurer <[email protected]>
CC: [email protected]
CC: Andy Lutomirski <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Linus Torvalds <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
compudj authored and shuahkh committed May 7, 2019
1 parent 5821ba9 commit fe22983
Showing 1 changed file with 70 additions and 74 deletions.
Loading

0 comments on commit fe22983

Please sign in to comment.