Package: gcc-6
Version: 6.3.0-14
Severity: normal

Dear maintainer,

in attached file you can see the code from CRIU project. gcc-6 fails to compile 
it,
while gcc-4.9 has no such problem.

$ gcc-6   call32.S 
/usr/bin/ld: /tmp/cczRnuRR.o: relocation R_X86_64_32S against `.text' can not 
be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

(The code is borrowed from Linux kernel and it also can be found at
<linux kernel>/tools/testing/selftests/x86/thunks.S file).

Regards,
Kirill


--- System information. ---
Architecture: 
Kernel:       Linux 4.11.0-rc7+

Debian Release: 9.0
  500 unstable        ftp.ru.debian.org 
  500 testing         ftp.ru.debian.org 
  500 stable-updates  ftp.ru.debian.org 
  500 stable          security.debian.org 
  500 stable          repo.skype.com 
  500 stable          ftp.ru.debian.org 
    1 experimental    ftp.ru.debian.org 

--- Package information. ---
Depends              (Version) | Installed
==============================-+-==============
cpp-6             (= 6.3.0-14) | 6.3.0-14
gcc-6-base        (= 6.3.0-14) | 
libcc1-0         (>= 6.3.0-14) | 
binutils             (>= 2.28) | 
libgcc-6-dev      (= 6.3.0-14) | 
libc6                (>= 2.14) | 
libgcc1             (>= 1:3.0) | 
libgmp10         (>= 2:5.0.1~) | 
libisl15             (>= 0.15) | 
libmpc3                        | 
libmpfr4            (>= 3.1.3) | 
libstdc++6              (>= 5) | 
zlib1g            (>= 1:1.1.4) | 


Recommends       (Version) | Installed
==========================-+-============
libc6-dev      (>= 2.13-5) | 2.24-10


Suggests                   (Version) | Installed
====================================-+-================
gcc-6-multilib                       | 6.3.0-14
gcc-6-doc               (>= 6.3.0-1) | 
gcc-6-locales           (>= 6.3.0-1) | 
libgcc1-dbg          (>= 1:6.3.0-14) | 
libgomp1-dbg           (>= 6.3.0-14) | 
libitm1-dbg            (>= 6.3.0-14) | 
libatomic1-dbg         (>= 6.3.0-14) | 
libasan3-dbg           (>= 6.3.0-14) | 
liblsan0-dbg           (>= 6.3.0-14) | 
libtsan0-dbg           (>= 6.3.0-14) | 
libubsan0-dbg          (>= 6.3.0-14) | 
libcilkrts5-dbg        (>= 6.3.0-14) | 
libmpx2-dbg            (>= 6.3.0-14) | 
libquadmath0-dbg       (>= 6.3.0-14) | 
/*
 * call32.S - assembly helpers for mixed-bitness code
 * From kernel selftests originally: tools/testing/selftests/x86/thunks.S
 * Copyright (c) 2015 Andrew Lutomirski
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * These are little helpers that make it easier to switch bitness on
 * the fly.
 */

#define __ALIGN         .align 4, 0x90
#define __ALIGN_STR     ".align 4, 0x90"

#define GLOBAL(name)            \
        .globl name;            \
        name:

#define ENTRY(name)             \
        .globl name;            \
        .type name, @function;  \
        __ALIGN;                \
        name:

#define END(sym)                \
        .size sym, . - sym

#define __USER32_CS     0x23
#define __USER_CS       0x33

        .text

/*
 * @rdi: Stack to use
 * @esi: Pointer to function for calling
 */
ENTRY(call32_from_64)
        /* Callee-saving registers due to ABI */
        pushq %rbx
        pushq %rbp
        pushq %r12
        pushq %r13
        pushq %r14
        pushq %r15
        pushfq

        /* Switch stacks */
        sub $8, %rdi
        mov %rsp,(%rdi)
        mov %rdi,%rsp

        /* Switch into compatibility mode */
        pushq $__USER32_CS
        pushq $1f
        lretq

1:
        .code32
        /* Run function and switch back */
        call *%esi
        jmp $__USER_CS,$1f
        .code64

1:
        /* Restore the stack */
        mov (%rsp),%rsp
        add $8, %rdi

        /* Restore registers */
        popfq
        popq %r15
        popq %r14
        popq %r13
        popq %r12
        popq %rbp
        popq %rbx
        ret
END(call32_from_64)

ENTRY(main)
        nop
END(main)

Reply via email to